private void HandleNetwork(object sender, InterServerEventArgs <NetworkMsg> e) { using (TimedLock.Lock(_dicLock)) { switch (e.Content.Code) { case NetworkCode.Join: if (AddServer(e.InstanceId, e.Content.Info)) { Log.InfoFormat("{0} ({1}, {2}) joined the network.", e.Content.Info.name, e.Content.Info.type, e.InstanceId); // make new server aware of this server Publish(Channel.Network, new NetworkMsg() { Code = NetworkCode.Join, Info = _settings.serverInfo }); NewServer?.Invoke(this, e); } else { UpdateServer(e.InstanceId, e.Content.Info); } break; case NetworkCode.Ping: if (!_servers.ContainsKey(e.InstanceId)) { Log.InfoFormat("{0} ({1}, {2}) re-joined the network.", e.Content.Info.name, e.Content.Info.type, e.InstanceId); } UpdateServer(e.InstanceId, e.Content.Info); ServerPing?.Invoke(this, e); break; case NetworkCode.Quit: Log.InfoFormat("{0} ({1}, {2}) left the network.", e.Content.Info.name, e.Content.Info.type, e.InstanceId); RemoveServer(e.InstanceId); ServerQuit?.Invoke(this, e); break; } } }
private void HandleNetwork(object sender, InterServerEventArgs <NetworkMsg> e) { using (TimedLock.Lock(_dicLock)) { switch (e.Content.Code) { case NetworkCode.Join: if (AddServer(e.InstanceId, e.Content.Info)) { // make new server aware of this server Publish(Channel.Network, new NetworkMsg { Code = NetworkCode.Join, Info = _settings.serverInfo }); NewServer?.Invoke(this, e); } else { UpdateServer(e.InstanceId, e.Content.Info); } break; case NetworkCode.Ping: UpdateServer(e.InstanceId, e.Content.Info); ServerPing?.Invoke(this, e); break; case NetworkCode.Quit: RemoveServer(e.InstanceId); ServerQuit?.Invoke(this, e); break; } } }