コード例 #1
0
            private void OnReqArrive(ulong hSocket, ushort usRequestID, uint len)
            {
                CSocketPeer sp = Seek(hSocket);

                if (sp == null)
                {
                    return;
                }
                sp.m_CurrReqID = usRequestID;
                CUQueue q = sp.m_qBuffer;

                q.SetSize(0);
                if (len > q.MaxBufferSize)
                {
                    q.Realloc(len);
                }
                if (len > 0)
                {
                    uint res;
                    unsafe
                    {
                        fixed(byte *buffer = q.m_bytes)
                        {
                            if (m_nMainThreads <= 1)
                            {
                                CUQueue.CopyMemory(buffer, (void *)ServerCoreLoader.GetRequestBuffer(hSocket), len);
                                res = len;
                            }
                            else
                            {
                                res = ServerCoreLoader.RetrieveBuffer(hSocket, len, buffer, false);
                            }
                        }
                    }
                    System.Diagnostics.Debug.Assert(res == len);
                    q.SetSize(res);
                }
                if (m_svsId != BaseServiceID.sidHTTP)
                {
                    q.OS     = sp.m_os;
                    q.Endian = sp.m_endian;
                    if ((tagBaseRequestID)usRequestID == tagBaseRequestID.idInterrupt)
                    {
                        CClientPeer cp = (CClientPeer)sp;
                        ulong       options;
                        q.Load(out options);
                        cp.OnIntNotified(options);
                        return;
                    }
                }
                else
                {
                    CHttpPeerBase hp = (CHttpPeerBase)sp;
                    hp.m_WebRequestName = null;
                    hp.m_vArg.Clear();
                    if (usRequestID == (ushort)tagHttpRequestID.idUserRequest)
                    {
                        uint    count;
                        sbyte[] reqName;
                        q.Load(out reqName);
                        hp.m_WebRequestName = CUQueue.ToString(reqName);
                        q.Load(out count);
                        for (uint n = 0; n < count; ++n)
                        {
                            object arg;
                            q.Load(out arg);
                            hp.m_vArg.Add(arg);
                        }
                    }
                }
                sp.OnRArrive(usRequestID, len);
            }