示例#1
0
        private static SerializedInfo ParseForKeepAlive(byte[] packet)
        {
            byte    sessionLength = packet[PacketConstants.SessionLengthIndex];
            string  sessionStr    = PacketConstants.SessionEncoding.GetString(packet, PacketConstants.HeadLength, sessionLength);
            Session session       = SessionMapping.Get(sessionStr);

            return(SerializedInfo.CreateForKeepAlive(session, true, packet));
        }
示例#2
0
        public void ReleaseResource(Session session)
        {
            var traderState = SessionManager.Default.GetTradingConsoleState(session);

            if (traderState != null && traderState.QuotationFilterSign != null)
            {
                QuotationFilterSignMapping.Remove(traderState.QuotationFilterSign);
            }
            SessionManager.Default.RemoveAllItem(session);
            SessionMapping.Remove(session.ToString());
        }
示例#3
0
 private void OnServerConnectionAvailable(object sender, SecureConnectionResults args)
 {
     try
     {
         if (args.AsyncException != null)
         {
             _Log.ErrorFormat("Client connection failed {0}", args.AsyncException);
             return;
         }
         SslInfo            sslInfo  = args.SecureInfo;
         Session            session  = SessionMapping.Get();
         Client             client   = new Client(sslInfo.SslStream, session, sslInfo.NetworkStream.BufferInUsed, sslInfo.Socket);
         SenderReceiverPair relation = new SenderReceiverPair(client, new ReceiveAgent());
         Application.Default.AgentController.Add(session, relation.Receiver, relation.Sender);
     }
     catch (Exception ex)
     {
         _Log.Error(ex);
     }
 }
示例#4
0
        private static SerializedInfo ParseForGeneral(byte[] packet)
        {
            byte sessionLength = packet[PacketConstants.SessionLengthIndex];

            byte[] contentLengthBytes = new byte[PacketConstants.ContentHeaderLength];
            Array.Copy(packet, PacketConstants.ContentLengthIndex, contentLengthBytes, 0, PacketConstants.ContentHeaderLength);
            int contentLength = contentLengthBytes.ToCustomerInt();

            byte[] contentBytes = new byte[contentLength];
            int    contentIndex = PacketConstants.HeadLength + sessionLength;

            Array.Copy(packet, contentIndex, contentBytes, 0, contentLength);
            string  sessionStr            = PacketConstants.SessionEncoding.GetString(packet, PacketConstants.HeadLength, sessionLength);
            Session session               = SessionMapping.Get(sessionStr);
            string  content               = PacketConstants.ContentEncoding.GetString(contentBytes);
            bool    isContentInJsonFormat = (packet[PacketConstants.SettingIndex] & PacketFirstHeadByteValue.IsJsonFormatMask) == PacketFirstHeadByteValue.IsJsonFormatMask;

            if (isContentInJsonFormat)
            {
                return(ParseJsonPacket(session, content));
            }
            return(ParseXmlPacket(session, content));
        }