private void SendMessageForTarget(TCPMessageType tcpMessageType, object message, string[] targetIds, bool enableDisconnected = true)
    {
        if (enableDisconnected && this.isDisconnected)
        {
            return;
        }
        Dictionary <string, object> dictionary = ClassSingleton <TCPMessageFactory> .Instance.CreateMessage(tcpMessageType, message);

        if (this.multiUsers == null || this.multiUsers.Length == 0)
        {
            return;
        }
        global::Debug.Log("targetIds: " + targetIds);
        if (Singleton <TCPUtil> .Instance == null)
        {
            global::Debug.LogWarning("this.myTCPUtil is null");
        }
        else
        {
            TCPUtil instance = Singleton <TCPUtil> .Instance;
            Dictionary <string, object> data = dictionary;
            if (BattleMultiBasicFunction.< > f__mg$cache0 == null)
            {
                BattleMultiBasicFunction.< > f__mg$cache0 = new Func <string, int>(Util.ToInt32);
            }
            instance.SendTCPRequest(data, targetIds.Select(BattleMultiBasicFunction.< > f__mg$cache0).ToList <int>(), this.myTCPKey);
            global::Debug.LogFormat("[TCPMessage]{0}を送信しました.", new object[]
            {
                tcpMessageType
            });
        }
    }
예제 #2
0
        public void sessionCreated(TCPSession session)
        {
            CAccount a = new CAccount();

            a.name     = "孙克宁";
            a.password = "******";
            TCPUtil.sendMessage(session, a);
            Debug.Log("和服务器建立连接");
        }
예제 #3
0
        public static void SetSystemMessageTCP()
        {
            TCPUtil instance = Singleton <TCPUtil> .Instance;

            if (ChatTools.< > f__mg$cache0 == null)
            {
                ChatTools.< > f__mg$cache0 = new Action <string>(ChatTools.AfterPrepareTCPServer);
            }
            instance.PrepareTCPServer(ChatTools.< > f__mg$cache0, "chat");
        }
예제 #4
0
        private static void AfterPrepareTCPServer(string server)
        {
            Singleton <TCPUtil> .Instance.MakeTCPClient();

            TCPUtil instance = Singleton <TCPUtil> .Instance;

            if (ChatTools.< > f__mg$cache1 == null)
            {
                ChatTools.< > f__mg$cache1 = new Action <Dictionary <string, object> >(ChatTools.GetTCPSystemReceponseData);
            }
            instance.SetTCPCallBackMethod(ChatTools.< > f__mg$cache1);
        }
예제 #5
0
        public NancyModuleRunner(Action <ConfigurableBootstrapper.ConfigurableBoostrapperConfigurator> configuration)
        {
            var host = "localhost";
            int port = TCPUtil.GetAvailableTCPPort(8081, 8090);

            BaseUrl = "http://" + host + ":" + port + "/";

            var bootStrapper = new ConfigurableBootstrapper(configuration);

            _nancyHost = new NancyHost(bootStrapper, new Uri(BaseUrl));
            _nancyHost.Start();
        }
예제 #6
0
        static void Main()
        {
            LogManager.WriteLog(LogManager.LOGINFO, "Program is Starting......");
            GlobalClass.ip       = ConfigurationManager.AppSettings["ip"].ToString();
            GlobalClass.httpport = ConfigurationManager.AppSettings["httpport"].ToString();
            GlobalClass.tcpport  = ConfigurationManager.AppSettings["tcpport"].ToString();
            TCPUtil t = new TCPUtil();

            t.StartThread();
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Login());
            TCPUtil.CloseConn();
        }
예제 #7
0
    protected override void ApplyBattleHierarchy(BattleStateHierarchyData hierarchyData, bool onAutoPlay = false, int continueWaitSecond = 10)
    {
        if (BattleStateManager.onAutoServerConnect)
        {
            return;
        }
        new GameObject("TCPUtil").AddComponent <TCPUtil>();
        TCPUtil   instance = Singleton <TCPUtil> .Instance;
        FieldInfo field    = instance.GetType().GetField("hostAddress", BindingFlags.Instance | BindingFlags.NonPublic);

        field.SetValue(instance, string.Format("{0}:{1}", "210.129.116.190", "18021"));
        this.SetData();
        base.ApplyBattleHierarchy(hierarchyData, onAutoPlay, continueWaitSecond);
    }
예제 #8
0
 private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (ShowInTaskbar)
     {
         if (MessageBox.Show("是否确认退出程序?", "退出", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
         {
             this.Dispose();
             TCPUtil.CloseConn();
             Util.Exit();
         }
         else
         {
             e.Cancel = true;
         }
     }
 }