/// <summary> /// Accepts incoming npc service connection. /// </summary> /// <param name="s">Accepted <see cref="Socket"/> object.</param> internal static void AcceptConnection(Socket s) { if (s == null || !s.Connected) { return; } if (!Active) { NetworkHelper.RemoteServiceInfo info = NetworkHelper.GetServiceInfo(s); if (info.ServiceType == ServiceType.NpcService) { m_NpcServerConnection = new InnerNetworkClient(info.ServiceId, info.ServiceType, s); NpcServiceRequestsHandlers nsrh = new NpcServiceRequestsHandlers(ref m_NpcServerConnection); //m_NpcServerConnection.OnDisconnected += new OnDisconnectedEventHandler(NpcServerConnection_OnDisconnected); m_NpcServerConnection.HandleDelegate = nsrh.Handle; m_NpcServerConnection.Send(new InitializeResponse(Settings.Default.ServiceUniqueID, ( byte )ServiceType.GameService, InitializeResponse.Accepted).ToPacket()); Active = true; Logger.WriteLine(Source.InnerNetwork, "Connection accepted for {0} (0x{1})", info.ServiceType, info.ServiceId.ToString("x2")); } } }
/// <summary> /// Accepts incoming npc service connection. /// </summary> /// <param name="s">Accepted <see cref="Socket"/> object.</param> internal static void AcceptConnection( Socket s ) { if ( s == null || !s.Connected ) return; if ( !Active ) { NetworkHelper.RemoteServiceInfo info = NetworkHelper.GetServiceInfo(s); if ( info.ServiceType == ServiceType.NpcService ) { m_NpcServerConnection = new InnerNetworkClient(info.ServiceId, info.ServiceType, s); NpcServiceRequestsHandlers nsrh = new NpcServiceRequestsHandlers(ref m_NpcServerConnection); //m_NpcServerConnection.OnDisconnected += new OnDisconnectedEventHandler(NpcServerConnection_OnDisconnected); m_NpcServerConnection.HandleDelegate = nsrh.Handle; m_NpcServerConnection.Send(new InitializeResponse(Settings.Default.ServiceUniqueID, ( byte )ServiceType.GameService, InitializeResponse.Accepted).ToPacket()); Active = true; Logger.WriteLine(Source.InnerNetwork, "Connection accepted for {0} (0x{1})", info.ServiceType, info.ServiceId.ToString("x2")); } } }