예제 #1
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
        }