public bool Send(string dest_name, object msg)
        {
            bool ret = false;

            if (null != dest_name)
            {
                if (world_id_ == 0)
                {
                    int handle = CenterClientApi.TargetHandle(dest_name);
                    if (handle != 0)
                    {
                        ret = Send(handle, msg);
                    }
                }
                else
                {
                    int handle = CenterHubApi.TargetHandle(world_id_, dest_name);
                    if (handle != 0)
                    {
                        ret = Send(handle, msg);
                    }
                }
            }
            return(ret);
        }
 private int GetMyHandle()
 {
     if (0 == m_MyHandle)
     {
         m_MyHandle = CenterClientApi.TargetHandle("Lobby");
     }
     return(m_MyHandle);
 }
Beispiel #3
0
        static void Main(string[] args)
        {
#if TEST_CENTER_CLIENT
            CenterClientApi.HandleNameHandleChangedCallback cb1 = HandleNameHandleChanged;
            CenterClientApi.HandleMessageCallback           cb2 = HandleMessage;
            CenterClientApi.HandleMessageResultCallback     cb3 = HandleMessageResult;
            CenterClientApi.HandleCommandCallback           cb4 = HandleCommand;
            byte[] bytes = Encoding.ASCII.GetBytes("test test test");
            CenterClientApi.Init("csharpclient", args.Length, args, cb1, cb2, cb3, cb4);

            CenterClientApi.ReloadConfigScript();
            CenterClientApi.ReloadConfigScript();

            for (; ;)
            {
                CenterClientApi.Tick();
                Thread.Sleep(10);

                int handle = CenterClientApi.TargetHandle("ServerCenter");
                if (handle > 0)
                {
                    bool ret = CenterClientApi.SendByHandle(handle, bytes, (ushort)bytes.Length);
                    CenterClientApi.SendCommandByHandle(handle, "output('test test test');");
                }
            }
            //CenterClientApi.Release();
#else
            CenterHubApi.HandleNameHandleChangedCallback cb1 = HandleNameHandleChanged2;
            CenterHubApi.HandleMessageCallback           cb2 = HandleMessage2;
            CenterHubApi.HandleMessageResultCallback     cb3 = HandleMessageResult2;
            CenterHubApi.HandleCommandCallback           cb4 = HandleCommand2;
            byte[] bytes = Encoding.ASCII.GetBytes("test test test");
            CenterHubApi.Init("centerhub", args.Length, args, cb1, cb2, cb3, cb4);

            CenterHubApi.ReloadConfigScript();
            CenterHubApi.ReloadConfigScript();

            for (; ;)
            {
                CenterHubApi.Tick();
                Thread.Sleep(10);

                int handle = CenterHubApi.TargetHandle(0, "hub2world0");
                if (handle > 0)
                {
                    bool ret = CenterHubApi.SendByHandle(0, handle, bytes, (ushort)bytes.Length);
                    CenterHubApi.SendCommandByHandle(0, handle, "output('test test test');");
                }
                handle = CenterHubApi.TargetHandle(1, "hub2world1");
                if (handle > 0)
                {
                    bool ret = CenterHubApi.SendByHandle(1, handle, bytes, (ushort)bytes.Length);
                    CenterHubApi.SendCommandByHandle(1, handle, "output('test test test');");
                }
            }
            //CenterHubApi.Release();
#endif
        }
Beispiel #4
0
 internal void ForwardToWorld(string userSvrName, object msg)
 {
     if (!string.IsNullOrEmpty(userSvrName) && null != msg)
     {
         int lobbyHandle = CenterClientApi.TargetHandle(userSvrName);
         if (lobbyHandle > 0)
         {
             ForwardToWorld(lobbyHandle, msg);
         }
     }
 }
Beispiel #5
0
 internal void TransmitToWorld(string userSvrName, string nodeName, NodeMessage msg)
 {
     if (!string.IsNullOrEmpty(userSvrName) && !string.IsNullOrEmpty(nodeName) && null != msg)
     {
         int lobbyHandle = CenterClientApi.TargetHandle(userSvrName);
         if (lobbyHandle > 0)
         {
             TransmitToWorld(lobbyHandle, nodeName, msg);
         }
     }
 }
Beispiel #6
0
        public bool Send(string dest_name, IMessage msg)
        {
            bool ret    = false;
            int  handle = CenterClientApi.TargetHandle(dest_name);

            if (handle != 0)
            {
                ret = Send(handle, msg);
            }
            return(ret);
        }