private void OnClosed(Session session) { _threadRun?.Cancel(); TryConnect(); Logger.Write(LogType.Info, 2, "AuthServer connection closed."); }
private void OnAccepted(Session session) { SecurePacket ntfPacket = new SecurePacket(Protocol.GetID("CS_Hello_Ntf")); Int32 seed = 0; // 각 8비트마다 0이 나오지 않는 임의 숫자 생성 seed |= Randomizer.NextNumber(1, 255) << 24; seed |= Randomizer.NextNumber(1, 255) << 16; seed |= Randomizer.NextNumber(1, 255) << 8; seed |= Randomizer.NextNumber(1, 255); // 패킷 암호화 키 생성 { String characterSet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"; char[] ascii = new char[16]; for (Int32 i = 0; i < 16; ++i) { Int32 val = seed & (0x6E << i); ascii[i] = characterSet[(val % characterSet.Length)]; } _aesIV = new string(ascii); for (Int32 i = 0; i < 16; ++i) { Int32 val = seed & (0xF4 << i); ascii[i] = characterSet[(val % characterSet.Length)]; } _aesKey = new string(ascii); } ntfPacket.PutInt32(seed); ntfPacket.Encrypt(Global.AES_IV, Global.AES_Key); base.SendPacket(ntfPacket); }
private void OnAccepted(Session session) { SecurePacket ntfPacket = new SecurePacket(Protocol.GetID("CS_Hello_Ntf")); ntfPacket.PutInt32(ResultCode.Ok); ntfPacket.PutInt32((Int32)ServerType.AuthServer); SendPacket(ntfPacket); }
public SessionMethodAsyncResult(Session session) { _session = session; _receivedBuffer = new StreamBuffer(2048); _dispatchBuffer = new StreamBuffer(2048); _responseSelector = new ResponseSelector(_session); }
private void OnConnected(Session session, bool connected) { if (_tcsConnect != null) { _tcsConnect.SetResult(connected); _tcsConnect = null; } }
private void OnClosed(Session session) { if (_svrInfo == null) return; _svrInfo.Status = ServerStatus.Inactivate; Logger.Write(LogType.Info, 2, "GameServer({0}) disconnected.", _svrInfo.Uid); _svrInfo = null; }
public SessionMethodAsyncEvent(Session session) { _session = session; _receivedBuffer = new StreamBuffer(2048); _dispatchBuffer = new StreamBuffer(2048); _saeaRecv = new SocketAsyncEventArgs(); _saeaRecv.Completed += ReceiveComplete; _responseSelector = new ResponseSelector(_session); }
private void OnClosed(Session session) { lock (_listTCS) { foreach (TCSData data in _listTCS) data.tcs.SetCanceled(); _listTCS.Clear(); } if (_tcsConnect != null) { _tcsConnect.SetException(new AegisException("Connection closed when trying ConnectAndWait()")); _tcsConnect = null; } }
private void OnReceived(Session session, StreamBuffer buffer) { PacketRequest packet = new PacketRequest(buffer); packet.SkipHeader(); try { packet.Dispatch(this, "On" + Protocol.GetName(packet.PacketId)); } catch (AegisException e) when (e.ResultCodeNo == AegisResult.BufferUnderflow) { Logger.Write(LogType.Err, 2, "Cannot read more data at PacketId(=0x{0:X}).", packet.PacketId); } catch (Exception e) { Logger.Write(LogType.Err, 2, e.ToString()); } }
private void OnConnected(Session session, Boolean connected) { if (connected == false) { TryConnect(); return; } PacketRequest reqPacket = new PacketRequest(Protocol.GetID("SS_Register_Req")); reqPacket.PutInt32(ServerCatalog.MyServerInfo.Uid); SendAndResponse(reqPacket, (resPacket) => { Logger.Write(LogType.Info, 2, "Connected to the AuthServer."); _threadRun = ThreadCancellable.CallPeriodically(1000, () => { PacketRequest ntfPacket = new PacketRequest(Protocol.GetID("SS_Traffic_Ntf")); ntfPacket.PutInt32(Statistics.CCU); SendPacket(ntfPacket); return Connected; }); }); }
private void OnReceived(Session session, StreamBuffer buffer) { SecurePacketRequest reqPacket = new SecurePacketRequest(buffer); reqPacket.Decrypt(_aesIV, _aesKey); reqPacket.SkipHeader(); try { // Authentication Packets if ((reqPacket.PacketId >> 8) == 0x20) { reqPacket.Dispatch(this, "On" + Protocol.GetName(reqPacket.PacketId)); } // Contents Packets else { _user = UserManager.Instance.FindUser(reqPacket.UserNo); if (_user == null) { ForceClose("Invalid UserNo."); return; } if (_user.LastSeqNo + 1 != reqPacket.SeqNo) { ForceClose("Invalid Sequence Number."); return; } _user.LastSeqNo = reqPacket.SeqNo; _user.Session = this; _user.LastPulse.Restart(); reqPacket.Dispatch(this, "On" + Protocol.GetName(reqPacket.PacketId)); } } catch (AegisException e) when (e.ResultCodeNo == AegisResult.BufferUnderflow) { Logger.Write(LogType.Err, 2, "Packet buffer underflow(PID=0x{0:X}).", reqPacket.PacketId); } }
private void OnClosed(Session session) { }
public ResponseSelector(Session session) { _session = session; _listResponseAction = new List<Data>(); }
private void OnReceived(Session session, StreamBuffer buffer) { SecurePacketRequest reqPacket = new SecurePacketRequest(buffer); reqPacket.Decrypt(ServerMain.AES_IV, ServerMain.AES_Key); reqPacket.SkipHeader(); try { reqPacket.Dispatch(this, "On" + Protocol.GetName(reqPacket.PacketId)); } catch (AegisException e) when (e.ResultCodeNo == AegisResult.BufferUnderflow) { Logger.Write(LogType.Err, 2, "Cannot read more data at PacketId(=0x{0:X}).", reqPacket.PacketId); } catch (Exception e) { Logger.Write(LogType.Err, 2, e.ToString()); } }
private void OnSessionInactivated(Session session) { lock (this) { ActiveSessions.Remove(session); InactiveSessions.Add(session); } }
private void OnReceived(Session session, StreamBuffer buffer) { SecurePacketRequest reqPacket = new SecurePacketRequest(buffer); reqPacket.Decrypt(_aesIV, _aesKey); reqPacket.SkipHeader(); Statistics.ReceivedBytes.Add(reqPacket.Size); Statistics.ReceivedCount.Add(1); try { if (reqPacket.PacketId == Protocol.GetID("CS_Login_Req")) OnCS_Login_Req(reqPacket); else { _user = UserManager.Find(reqPacket.UserNo); if (_user == null) { ForceClose("Invalid UserNo."); return; } if (reqPacket.SeqNo != _user.SeqNo + 1) { ForceClose("Invalid Sequence Number."); return; } _user.SeqNo = reqPacket.SeqNo; _user.Session = this; reqPacket.Dispatch(_user, "On" + Protocol.GetName(reqPacket.PacketId)); UserManager.HeartPulse(_user); } } catch (AegisException e) when (e.ResultCodeNo == AegisResult.BufferUnderflow) { Logger.Write(LogType.Err, 2, "Cannot read more data at PacketId(=0x{0:X}).", reqPacket.PacketId); } catch (Exception e) { Logger.Write(LogType.Err, 2, e.ToString()); } }
internal AwaitableMethod(Session session) { _session = session; _session.NetworkEvent_Connected += OnConnected; _session.NetworkEvent_Closed += OnClosed; }
private void OnAccepted(Session session) { _svrInfo = null; }
private void OnReceived(Session session, StreamBuffer buffer) { }
internal AwaitableMethod(Session session) { _session = session; _session.EventConnect += NetworkConnected; _session.EventClose += NetworkClosed; }
private void OnClosed(Session session) { _user?.Logout(); _user = null; }
private void OnClosed(Session session) { if (_user != null) _user.Session = null; _user = null; }