void Server_ClientConnected(object sender, INetworkSocket e) { ActorChannel actorChannel = new ActorChannel(e); ServerSocketToChannel.Add(e, actorChannel); RaiseChannelAdded(actorChannel); }
protected void RaiseChannelAdded(ActorChannel channel) { Channels.Add(channel); var channelAddedEvent = new ChannelAddedEvent(channel); InputQueue.Add(channelAddedEvent); }
protected void RaiseChannelRemoved(ActorChannel channel) { if (!Channels.Remove(channel)) { throw new InvalidOperationException("Failed to remove channel from actor"); } var channelRemovedEvent = new ChannelRemovedEvent(channel); InputQueue.Add(channelRemovedEvent); }
protected void RaiseMessageReceived(ActorChannel channel, object message) { var messageReceivedEvent = new MessageReceivedEvent(channel, message); InputQueue.Add(messageReceivedEvent); }
protected virtual void OnMessageReceived(ActorChannel channel, object message) { }
protected virtual void OnChannelRemoved(ActorChannel channel) { }
protected virtual void OnChannelCreated(ActorChannel channel) { }
protected void SendMessage(ActorChannel channel, object message) { channel.Socket.SendMessage(message); }