void SendToClient(Session session, Packet packet)
        {
            if (session == null)
                return;

            session.Send(packet.GetData(), 0, packet.GetTotalPacketSize());
        }
 public void Send_CS_ECHO_APP_ACK(Session session, string data, long tick)
 {
     Packet sendPacket = new Packet(ProtocolID.CS_ECHO_APP_ACK);
     sendPacket.WriteString(data);
     sendPacket.WriteLong(tick);
     SendToClient(session, sendPacket);
 }
Esempio n. 3
0
        protected override void OnSessionReceived(Session session, byte[] buffer, int offset, int length)
        {
            base.OnSessionReceived(session, buffer, offset, length);

            Packet recvPacket = new Packet(buffer, length);
            Protocol_Handler(session, recvPacket);
        }
        void On_CS_ECHO_APP_REQ(Session session, Packet packet)
        {
            string data = packet.ReadString();
            long tick = packet.ReadLong();

            Logger.Debug(string.Format("data:{0} tick:{1}", data, tick));
            Send_CS_ECHO_APP_ACK(session, data, tick);
        }
Esempio n. 5
0
 void Protocol_Handler(Session session, Packet packet)
 {
     switch (packet.GetID())
     {
         case ProtocolID.CS_ECHO_APP_REQ:{ On_CS_ECHO_APP_REQ(session, packet); } break;
         default:
             {
                 Logger.Warning(string.Format("Receive unknown packet id:{0}", packet.GetID()));
                 // 끊어버려?
             }
             break;
     }
     if (packet.GetRemainDataSize() > 0)
     {
         Logger.Warning(string.Format("Remain packet data [{0}] {1} bytes", ((ProtocolID)packet.GetID()).ToString(), packet.GetRemainDataSize()));
     }
 }
Esempio n. 6
0
 protected virtual void OnSessionDisconnected(Session session, CloseReason reason)
 {
     Logger.Debug(string.Format("OnSessionDisconnected:{0}", session.m_ID));
     if (session != null && m_RecvSAEAPool != null && m_SendSAEAPool != null)
     {
         session.m_RecvSAEA.UserToken = null;
         session.m_SendSAEA.UserToken = null;
         // TODO 버퍼 셋팅도 다시 해줘야 하나?
         // 최초 BufferManager에서 할당받은 위치겠지만
         m_RecvSAEAPool.Push(session.m_RecvSAEA);
         m_SendSAEAPool.Push(session.m_SendSAEA);
     }
     Session removeSession = null;
     m_Sessions.TryRemove(session.m_ID, out removeSession);
 }
Esempio n. 7
0
 protected virtual void OnSessionConnected(Session session)
 {
     Logger.Debug(string.Format("OnSessionConnected:{0}", session.m_ID));
 }
Esempio n. 8
0
 protected virtual void OnSessionReceived(Session session, byte[] buffer, int offset, int length)
 {
     //Logger.Debug(string.Format("OnSessionReceived:{0}", session.m_ID));
 }
Esempio n. 9
0
 protected virtual void OnSessionError(Session session, string message, Exception e)
 {
     Logger.Error(string.Format("OnSessionError:{0} {1} {2} {3}", session.m_ID, message, e != null ? e.Message : string.Empty, e != null ? e.StackTrace : string.Empty));
 }