/// <summary> /// Creates a new instance of the <see cref="IncomingChatListenerPeer"/> class. /// </summary> /// <param name="initRequest"></param> /// <param name="application"> </param> public IncomingChatListenerPeer(InitRequest initRequest, ChatApplication application) : base(initRequest.Protocol, initRequest.PhotonPeer) { this.application = application; this.chat = MmoChat.Instance; this.channels = new Dictionary <int, Channel>(); }
/// <summary> /// Creates a new instance of the <see cref="ChatSession"/> class, /// </summary> public ChatSession(int sessionId, string name, IChatServer server, MmoChat chat) { this.server = server; this.chat = chat; this.sessionId = sessionId; this.name = name; this.joinedChannels = new List <IChannel>(); this.SessionState = ChatSessionState.Login; this.chat.SyncFiber.Enqueue(DoAddSession); }
/// <summary> /// Creates a new instance of the <see cref="ChatServerPeer"/> class. /// </summary> /// <param name="initResponse"></param> /// <param name="application"></param> public ChatServerPeer(InitResponse initResponse, ChatApplication application) : base(initResponse, application) { this.application = application; this.messageFiber = new ThreadFiber(new DefaultQueue(), "ChatMessageFiber", true, ThreadPriority.Highest); this.messageFiber.Start(); this.chat = MmoChat.Instantiate(this); // the lock will wait indefinitely this.sessions = new ConcurrentStorageMap <int, ISession>(-1); this.RequestFiber.Enqueue(this.Register); }
/// <summary> /// Instantiates the singleton of the <see cref="MmoChat"/>. If it has already been instantiated returns the old instance. /// </summary> public static MmoChat Instantiate(IChatServer server) { lock (typeof(MmoChat)) return(Instance ?? (Instance = new MmoChat(server))); }