Exemplo n.º 1
0
        void SendToClient(Session session, Packet packet)
        {
            if (session == null)
                return;

            session.Send(packet.GetData(), 0, packet.GetTotalPacketSize());
        }
Exemplo n.º 2
0
 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);
 }
Exemplo 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);
        }
Exemplo n.º 4
0
        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);
        }
Exemplo 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()));
     }
 }
Exemplo 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);
 }
Exemplo n.º 7
0
 protected virtual void OnSessionConnected(Session session)
 {
     Logger.Debug(string.Format("OnSessionConnected:{0}", session.m_ID));
 }
Exemplo n.º 8
0
 protected virtual void OnSessionReceived(Session session, byte[] buffer, int offset, int length)
 {
     //Logger.Debug(string.Format("OnSessionReceived:{0}", session.m_ID));
 }
Exemplo 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));
 }