private void ProcessMessage(IServer server, ISession session, object message) { if (message is Ping) { server.Send(new Pong(), session); } else if (message is BroadSubscriber) { BroadSubscriber bs = (BroadSubscriber)message; RegisterRemoteSubscribers(bs.NodeID, bs.Name); Loger.Process(LogType.DEBUG, "registered remote subscriber [{0}]", bs.Name); } else if (message is GetSubscribers) { GetSubscribersResponse response = new GetSubscribersResponse(); response.NodeID = ID; response.Subscribers = mLocalSubscriberCenter.GetAll(); server.Send(response, session); } else if (message is BroadRemoveSubscriber) { BroadRemoveSubscriber remove = (BroadRemoveSubscriber)message; UnRegisterRemoteSubscribers(remove.Name); } else if (message is Message) { ((Message)message).Track("node receive message"); Publish((Message)message); ((Message)message).EndTrack("node receive message completed!", this); } else { } }
public void UnRegister(string name) { ISubscriber subscriber = mLocalSubscriberCenter.UnRegister(name); if (subscriber != null) { BroadRemoveSubscriber remove = new BroadRemoveSubscriber(); remove.NodeID = this.ID; remove.Name = name; mRemoteNodeCenter.Send(remove); Loger.Process(LogType.INFO, "unregistered loal subscriber [{0}]", name); } }