开发者

Only one instance of object for all visitors?

开发者 https://www.devze.com 2023-03-14 22:51 出处:网络
I have a dedicated server with a Skype client running on it. I intend to use the Skype COM API to make an AJAX-based live-chat on my website.

I have a dedicated server with a Skype client running on it. I intend to use the Skype COM API to make an AJAX-based live-chat on my website.

However, for this to work, I need an object to be initialized only once for all visitors, and I need to be able to use that very same object across visitors too开发者_高级运维. How can this be done?


maybe you can put it on your application

System.Web.HttpApplication

class and instance it on

Application_Start()

or

Application_Init()


You are looking for a singleton pattern. However you will get global state, it would probably better to share the chat messages using a database of some sort. Global state is tricky to test.


I ended up using the Application["keyhere"] object to simulate singleton properly.

0

精彩评论

暂无评论...
验证码 换一张
取 消