示例#1
0
            private void OnSwitch(ulong hSocket, uint oldServiceId, uint newServiceId)
            {
                if (m_nMainThreads == uint.MaxValue)
                {
                    m_nMainThreads = ServerCoreLoader.GetMainThreads();
                }
                CBaseService bsOld;

                if (oldServiceId != BaseServiceID.sidStartup && (bsOld = SeekService(oldServiceId)) != null)
                {
                    bsOld.ReleasePeer(hSocket, false, newServiceId);
                }
                CBaseService bsNew = SeekService(newServiceId);

                if (bsNew != null)
                {
                    CSocketPeer sp = bsNew.CreatePeer(hSocket, newServiceId);
                    sp.m_bRandom = bsNew.ReturnRandom;
                    if (newServiceId == BaseServiceID.sidHTTP)
                    {
                        CHttpPeerBase hp = (CHttpPeerBase)sp;
                        hp.m_bHttpOk = false;
                    }
                    else
                    {
                        sp.m_os             = ServerCoreLoader.GetPeerOs(hSocket, ref sp.m_endian);
                        sp.m_qBuffer.OS     = sp.m_os;
                        sp.m_qBuffer.Endian = sp.m_endian;
                    }
                    sp.OnSwitch(oldServiceId);
                }
            }
示例#2
0
            internal virtual void OnChatComing(tagChatRequestID chatRequestID)
            {
                uint    svsId = ServerCoreLoader.GetSvsID(m_sh);
                CUQueue q     = m_qBuffer;

                if (svsId != BaseServiceID.sidHTTP)
                {
                    bool endian           = false;
                    tagOperationSystem os = ServerCoreLoader.GetPeerOs(m_sh, ref endian);
                    q.Endian = endian;
                    q.OS     = os;
                }
                switch (chatRequestID)
                {
                case tagChatRequestID.idEnter:
                {
                    object objGroups;
                    q.Load(out objGroups);
                    OnSubscribe((uint[])objGroups);
                }
                break;

                case tagChatRequestID.idExit:
                {
                    OnUnsubscribe(ChatGroups);
                }
                break;

                case tagChatRequestID.idSendUserMessage:
                {
                    object msg;
                    string user;
                    q.Load(out user).Load(out msg);
                    OnSendUserMessage(user, msg);
                }
                break;

                case tagChatRequestID.idSpeak:
                {
                    object msg;
                    object groups;
                    q.Load(out groups).Load(out msg);
                    OnPublish(msg, (uint[])groups);
                }
                break;

                default:
                    ServerCoreLoader.SendExceptionResult(m_sh, "Unexpected chat request", Environment.StackTrace, (ushort)chatRequestID, 0);
                    break;
                }
            }