Ejemplo n.º 1
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);
 }
Ejemplo n.º 2
0
        void SendToClient(Session session, Packet packet)
        {
            if (session == null)
                return;

            session.Send(packet.GetData(), 0, packet.GetTotalPacketSize());
        }
Ejemplo 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);
        }
Ejemplo 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);
        }
Ejemplo n.º 5
0
        public BinaryResult ProcessReceive(Packet recvPacket)
        {
            string data = recvPacket.ReadString();
            long tick = recvPacket.ReadLong();

            Packet sendPacket = new Packet(ProtocolID.CS_ECHO_WEB_ACK);
            sendPacket.WriteString(data);
            sendPacket.WriteLong(tick);

            return new PacketResult(sendPacket);
        }
Ejemplo n.º 6
0
        public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
        {
            var request = controllerContext.HttpContext.Request;
            if (request == null)
                return null;

            // TODO 여기도 메모리풀 사용 고려

            byte[] buffer = new byte[request.ContentLength];
            request.InputStream.Read(buffer, 0, buffer.Length);
            Packet packet = new Packet(buffer, buffer.Length);
            return packet;
        }
Ejemplo n.º 7
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()));
     }
 }
Ejemplo n.º 8
0
 public PacketResult(Packet packet)
 {
     Data = new ArraySegment<byte>(packet.GetData(), 0, packet.GetTotalPacketSize());
 }