예제 #1
0
        public DispatchAttribute getCopy()
        {
            DispatchAttribute dispatchAttribute = new DispatchAttribute();

            if (dispatchAttribute != null)
            {
                dispatchAttribute.uid             = this.uid;
                dispatchAttribute.vid             = this.vid;
                dispatchAttribute.type            = this.type;
                dispatchAttribute.algorithm       = this.algorithm;
                dispatchAttribute.data            = this.data;
                dispatchAttribute.cbCallBack      = this.cbCallBack;
                dispatchAttribute.cbCacheProcess  = this.cbCacheProcess;
                dispatchAttribute.owner           = this.owner;
                dispatchAttribute.block_no        = 0;
                dispatchAttribute.dispatchPointer = -1;
                dispatchAttribute.request         = this.request;
                dispatchAttribute.tStart          = (long)Environment.TickCount;
                dispatchAttribute.reloadDB        = 1;
                dispatchAttribute.discard_if_jam  = this.discard_if_jam;
                dispatchAttribute.cid             = this.cid;
                dispatchAttribute.guid            = this.guid;
                dispatchAttribute.alltype         = this.alltype;
                dispatchAttribute.attached        = this.attached;
                dispatchAttribute.operation       = this.operation;
                dispatchAttribute._msgHandler     = this._msgHandler;
            }
            return(dispatchAttribute);
        }
예제 #2
0
 public virtual void setSocket(Socket sock)
 {
     lock (this._lockContext)
     {
         this._sock       = sock;
         this._dsContext  = null;
         this._sqlContext = null;
         if (this._datasetRequestQueue != null)
         {
             this._datasetRequestQueue.Clear();
         }
         this._curDispatchAttrib = null;
     }
 }
예제 #3
0
 public ConnectContext(Socket sock)
 {
     this._sock                = sock;
     this._loginState          = 0;
     this.RemoteEndPoint       = (sock.RemoteEndPoint as IPEndPoint);
     this._requestSN           = 0uL;
     this._dsContext           = new ConnectContext.SerializeContext();
     this._sqlContext          = new ConnectContext.SerializeContext();
     this._datasetRequestQueue = new Queue <DispatchAttribute>();
     this._curDispatchAttrib   = null;
     this._vid              = -1L;
     this._bKicked          = false;
     this._bServiceWillDown = false;
     this._lastRequesdtType = -1;
     this._sslPendingQ      = new ConcurrentQueue <BufferState>();
     this._sslSending       = false;
 }
예제 #4
0
 public DispatchAttribute(DispatchAttribute attrib)
 {
     this.uid             = attrib.uid;
     this.vid             = attrib.vid;
     this.cid             = attrib.cid;
     this.type            = attrib.type;
     this.algorithm       = attrib.algorithm;
     this.data            = attrib.data;
     this.cbCallBack      = attrib.cbCallBack;
     this.cbCacheProcess  = attrib.cbCacheProcess;
     this.reloadDB        = attrib.reloadDB;
     this.discard_if_jam  = attrib.discard_if_jam;
     this.guid            = attrib.guid;
     this.alltype         = attrib.alltype;
     this.attached        = attrib.attached;
     this.operation       = attrib.operation;
     this.owner           = null;
     this._msgHandler     = attrib._msgHandler;
     this.block_no        = 0;
     this.dispatchPointer = -1;
     this.request         = "";
     this.tStart          = (long)Environment.TickCount;
 }
예제 #5
0
 private void ReceiveDataset(ref ConnectContext.SerializeContext context, byte[] packet)
 {
     try
     {
         int num = 0;
         this._headBytes = BitConverter.GetBytes(ecoServerProtocol.swap64(this._header));
         int uid = (int)ecoServerProtocol.swap16((ushort)BitConverter.ToInt16(this._receiveBuffer, num));
         num += 2;
         int vid = (int)ecoServerProtocol.swap16((ushort)BitConverter.ToInt16(this._receiveBuffer, num));
         num += 2;
         int type = (int)ecoServerProtocol.swap16((ushort)BitConverter.ToInt16(this._receiveBuffer, num));
         num += 2;
         int num2 = (int)packet[num];
         num++;
         int num4;
         if ((num2 & 1) != 0)
         {
             DateTime arg_77_0 = DateTime.Now;
             Common.WriteLine("Dataset from server: type={0}, uid={1}, vid={2}", new string[]
             {
                 type.ToString("X8"),
                 uid.ToString(),
                 vid.ToString()
             });
             ecoServerProtocol.swap16((ushort)BitConverter.ToInt16(packet, num));
             num += 2;
             uint num3 = ecoServerProtocol.swap32((uint)BitConverter.ToInt32(packet, num));
             num += 4;
             num4 = (int)ecoServerProtocol.swap16((ushort)BitConverter.ToInt16(packet, num));
             num += 2;
             uint num5 = ecoServerProtocol.swap32((uint)BitConverter.ToInt32(packet, num));
             num += 4;
             context._compress = (int)(num5 & 15u);
             num4 -= 4;
             context._hashDataSet = new byte[num4];
             Array.Copy(packet, num, context._hashDataSet, 0, num4);
             num4 = 0;
             context._dataSize     = 0;
             context._dataBuffer   = new byte[num3];
             context._tPacketStart = (long)Environment.TickCount;
             Common.WriteLine("    DataSet begin, uid={0}, vid={1}, type={2}, total={3}, Elapsed=0", new string[]
             {
                 uid.ToString(),
                 vid.ToString(),
                 type.ToString("X8"),
                 num3.ToString()
             });
         }
         else
         {
             ecoServerProtocol.swap16((ushort)BitConverter.ToInt16(packet, num));
             num += 2;
             num4 = (int)ecoServerProtocol.swap16((ushort)BitConverter.ToInt16(packet, num));
             num += 2;
         }
         if (context._dataBuffer != null && packet != null && num4 > 0)
         {
             Array.Copy(packet, num, context._dataBuffer, context._dataSize, num4);
             context._dataSize += num4;
         }
         if ((num2 & 2) != 0)
         {
             if (context._dataBuffer != null)
             {
                 long   num6  = Common.ElapsedTime(context._tPacketStart);
                 bool   flag  = false;
                 MD5    mD    = MD5.Create();
                 byte[] first = mD.ComputeHash(context._dataBuffer, 0, context._dataBuffer.Length);
                 if (context._hashDataSet != null && !first.SequenceEqual(context._hashDataSet))
                 {
                     flag = true;
                 }
                 DateTime arg_255_0 = DateTime.Now;
                 if (flag)
                 {
                     Common.WriteLine("    DataSet crashed: uid={0}, vid={1}, type={2}, size={3}, elapsed: {4}", new string[]
                     {
                         uid.ToString(),
                         vid.ToString(),
                         type.ToString("X8"),
                         context._dataBuffer.Length.ToString(),
                         num6.ToString()
                     });
                 }
                 else
                 {
                     Common.WriteLine("    DataSet end: uid={0}, vid={1}, type={2}, size={3}, elapsed: {4}", new string[]
                     {
                         uid.ToString(),
                         vid.ToString(),
                         type.ToString("X8"),
                         context._dataBuffer.Length.ToString(),
                         num6.ToString()
                     });
                 }
                 DispatchAttribute dispatchAttribute = new DispatchAttribute();
                 dispatchAttribute.uid       = uid;
                 dispatchAttribute.vid       = vid;
                 dispatchAttribute.type      = type;
                 dispatchAttribute.algorithm = context._compress;
                 dispatchAttribute.data      = context._dataBuffer;
                 dispatchAttribute.owner     = this._owner;
                 Serialization serialization = new Serialization();
                 serialization.StartDecompressThread(dispatchAttribute);
             }
             context._dataSize   = 0;
             context._dataBuffer = null;
         }
     }
     catch (Exception ex)
     {
         Common.WriteLine(ex.Message, new string[0]);
     }
 }
예제 #6
0
        public bool setDataSet(DispatchAttribute attrib)
        {
            bool flag = (attrib.type & 1) != 0;
            bool result;

            lock (this._lockContext)
            {
                if (this._curDispatchAttrib != null)
                {
                    if (this._isRealTimePending && flag && attrib.discard_if_jam > 0)
                    {
                        string text = "";
                        if (this._curDispatchAttrib != null)
                        {
                            text += this._curDispatchAttrib.type.ToString();
                        }
                        int num = 0;
                        foreach (DispatchAttribute current in this._datasetRequestQueue)
                        {
                            if (num == 0)
                            {
                                text += ":";
                            }
                            else
                            {
                                text += ",";
                            }
                            text += current.type;
                            num++;
                        }
                        Common.WriteLine("XXXXXXXXXXXXXX Realtime data is already on the way @setDataSet({0}), data discarded", new string[]
                        {
                            text
                        });
                    }
                    else
                    {
                        if (flag)
                        {
                            this._isRealTimePending = true;
                        }
                        this._datasetRequestQueue.Enqueue(attrib);
                        string text2 = "";
                        if (this._curDispatchAttrib != null)
                        {
                            text2 += this._curDispatchAttrib.type.ToString();
                        }
                        int num2 = 0;
                        foreach (DispatchAttribute current2 in this._datasetRequestQueue)
                        {
                            if (num2 == 0)
                            {
                                text2 += ":";
                            }
                            else
                            {
                                text2 += ",";
                            }
                            text2 += current2.type;
                            num2++;
                        }
                        DateTime arg_1A6_0 = DateTime.Now;
                        Common.WriteLine("(S)Dispatch pending @setDataSet, push data in queue({0}): type={1}, uid={2}, {3} bytes", new string[]
                        {
                            text2,
                            this._curDispatchAttrib.type.ToString("X8"),
                            this._curDispatchAttrib.uid.ToString(),
                            this._curDispatchAttrib.data.Length.ToString()
                        });
                    }
                    result = false;
                }
                else
                {
                    this._curDispatchAttrib = attrib;
                    if (this._curDispatchAttrib.data != null)
                    {
                        if (flag)
                        {
                            this._isRealTimePending = true;
                        }
                        long num3 = Common.ElapsedTime(this._curDispatchAttrib.tStart);
                        Common.WriteLine("    New Dispatch: type={0}, uid={1}, {2} bytes, Elapsed={3}", new string[]
                        {
                            this._curDispatchAttrib.type.ToString("X8"),
                            this._curDispatchAttrib.uid.ToString(),
                            this._curDispatchAttrib.data.Length.ToString(),
                            num3.ToString()
                        });
                    }
                    else
                    {
                        this._curDispatchAttrib = null;
                    }
                    result = (this._curDispatchAttrib != null);
                }
            }
            return(result);
        }