Beispiel #1
0
    static public void LogError(object message, Object context)
    {
        if (EnableLog || EnableError)
        {
            if (Application.platform == RuntimePlatform.WindowsEditor ||
                Application.platform == RuntimePlatform.OSXEditor)
            {
                Debug.LogError(message, context);
            }
            else if (EnableConsolLog)
            {
                Debug.LogError(message, context);
            }



            if (EnableClient)
            {
                if (client == null)
                {
                    client = new AsyncUdpClient();
                }


                client.BroadCastMsg(sendPort + 2, System.Text.Encoding.UTF8.GetBytes(message.ToString()));
            }
        }
    }
Beispiel #2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            picBox.Size = panel1.Size;
            IP          = ConfigHelper.GetConfigString("IP");
            port        = ConfigHelper.GetConfigInt("Port");

            string[] paths = ConfigHelper.GetConfigString("file").Split(new char[1] {
                '|'
            }, StringSplitOptions.RemoveEmptyEntries);
            foreach (string path in paths)
            {
                if (!string.IsNullOrEmpty(path))
                {
                    comboBox_fileselect.Items.Add(path);
                    comboBox_fileselect.SelectedItem = path;
                    if (System.IO.Path.GetExtension(path) == ".png" || System.IO.Path.GetExtension(path) == ".jpg")
                    {
                        lImg.Add(comboBox_fileselect.Items.Count - 1, Image.FromFile(path));
                    }
                }
            }

            //TCP连接
            //S = new NewSocket();
            //S.Init(IP, port);
            //timer2.Start();
            //UDP
            AUC = new AsyncUdpClient(IP, port, 10010);
            t   = new Thread(DUPSocket);
            t.Start();
            timer3.Start();

            ShowIP_label.Text = "IP:" + IP.ToString() + "|Port:" + port;
        }
Beispiel #3
0
 public UdpClientAdapter(AsyncUdpClient udpClient)
 {
     if (udpClient != null)
     {
         this.udpClient = udpClient;
     }
 }
Beispiel #4
0
    // Start is called before the first frame update
    void Start()
    {
        m_CreatConnectionBtn.onClick.AddListener(OnCreateConnection);


        AsyncUdpClient.getInstance().SetDispatcher(new BroadcastDispatcher());
        AsyncUdpClient.getInstance().Start();
    }
Beispiel #5
0
 public static AsyncUdpClient getInstance()
 {
     if (mInstance == null)
     {
         mInstance = new AsyncUdpClient();
     }
     return(mInstance);
 }
Beispiel #6
0
    private void OnDestroy()
    {
        m_CreatConnectionBtn.onClick.RemoveListener(OnCreateConnection);


        AsyncUdpClient.getInstance().Close();

        foreach (var item in m_TcpConnections)
        {
        }
    }
Beispiel #7
0
        static void Main(string[] args)
        {
            //AsyncUdpSever.Servermain("192.168.1.103");
            AsyncUdpClient.Init();

            while (true)
            {
                string Rmsg = Console.ReadLine();
                AsyncUdpClient.auc.SendMsg(Rmsg);
                //SendMessage1("127.0.0.1",Rmsg,2009);
            }
        }
Beispiel #8
0
    static public void UdpLog(object message)
    {
        if (client == null)
        {
            client = new AsyncUdpClient();
        }



        client.BroadCastMsg(sendPort, System.Text.Encoding.UTF8.GetBytes(message.ToString()));
        client.BroadCastMsg(sendPort + 1, System.Text.Encoding.UTF8.GetBytes(message.ToString()));
        client.BroadCastMsg(sendPort + 2, System.Text.Encoding.UTF8.GetBytes(message.ToString()));
    }
        public void Start()
        {
            client = new AsyncUdpClient <Enum>(54322);
            client.JoinMulticastGroup("239.0.1.1");
            client.OnDataReceived += OnDataReceived;
            client.Start();
            Console.ReadLine();
            client.Stop();

            /*
             * worldServer = new TcpServer("192.168.255.128", 13579);
             * worldServer.OnClientConnected += OnClientConnected;
             * worldServer.Start();
             */
        }
Beispiel #10
0
 /// <summary>
 /// 断开连接
 /// </summary>
 public void OnDisconnect()
 {
     if (m_TcpClient == null)
     {
         return;
     }
     m_TcpClient.OnMessage -= OnTcpMessage;
     m_TcpClient.Disconnect();
     m_TcpClient = null;
     if (m_UdpClient == null)
     {
         return;
     }
     m_UdpClient.OnMessage -= OnUdpMessage;
     m_UdpClient.Disconnect();
     m_UdpClient = null;
 }
Beispiel #11
0
 AsyncUdpClient()
 {
     mInstance = this;
 }
Beispiel #12
0
 /// <summary>
 /// 初始化Udp网络连接
 /// </summary>
 public void InitUdpClient()
 {
     m_UdpClient            = new AsyncUdpClient(GameData.m_UdpIP, GameData.m_UdpPort);
     m_UdpClient.OnMessage += OnUdpMessage;
 }
        public ArenaClientForm()
        {
            InitializeComponent();

            MyIniParser = new IniParser();

            string strWidth = MyIniParser.GetSetting(IniConstants.SECTION_SETTINGS, IniConstants.CLIENT_WINDOW_WIDTH, 800);
            string strHeight = MyIniParser.GetSetting(IniConstants.SECTION_SETTINGS, IniConstants.CLIENT_WINDOW_HEIGHT, 500);
            int width, height;
            if (int.TryParse(strWidth, out width))
                this.Width = width;
            if (int.TryParse(strHeight, out height))
                this.Height = height;
            LoginUserNameTextBox.Text = MyIniParser.GetSetting(IniConstants.SECTION_SETTINGS, IniConstants.CLIENT_LOGIN_NAME, string.Empty);
            //ServerAddressComboBox.Text = MyIniParser.GetSetting(IniConstants.SECTION_SETTINGS, IniConstants.CLIENT_SERVER_ADDRESS, "127.0.0.1:30000");

            string[] serverList = MyIniParser.GetSetting(IniConstants.SECTION_SETTINGS, IniConstants.CLIENT_SERVER_LIST, string.Empty).Split(',');
            foreach (string s in serverList)
            {
                if (s != string.Empty)
                {
                    ServerAddressComboBox.Items.Add(s);
                    ServerListCount++;
                }
            }

            if (ServerListCount > 0)
            {
                ServerAddressComboBox.SelectedIndex = 0;
                ServerAddressComboBox.Text = (string)ServerAddressComboBox.SelectedItem;
            }
            else
            {
                ServerAddressComboBox.Text = string.Empty;
            }

            ServerAddressComboBox.Items.Add("----------履歴----------");

            serverList = MyIniParser.GetSetting(IniConstants.SECTION_SETTINGS, IniConstants.CLIENT_SERVER_HISTORY, string.Empty).Split(',');
            foreach (string s in serverList)
            {
                if (s != string.Empty)
                {
                    if (ServerHistory.Count >= MaxServerHistory) break;

                    ServerAddressComboBox.Items.Add(s);
                    ServerHistory.Add(s);
                }
            }
            ServerHistory.Reverse();

            GoTo(OperationMode.Offline);

            ArenaSessionClient = new AsyncTcpClient(new SessionHandler(this));
            ArenaTunnelClient = new AsyncUdpClient(new TunnelHandler(this));

            //UdpPortTextBox_TextChanged(null, null);

            ResetServerStatusBar();
            RefreshLanAdapterList();

            AppendToChatTextBoxDelegate = delegate(string message, Color color, CheckBox notDisplay)
            {
                if (notDisplay != null && notDisplay.Checked) return;
                try
                {
                    ChatLogTextBox.AppendText(message);
                    ChatLogTextBox.AppendText(Environment.NewLine);
                    //ChatLogTextBox.ScrollToCaret();

                }
                catch (Exception ex)
                {
                    logTextBox.AppendText(message);
                    logTextBox.AppendText(ex.ToString());
                }
            };

            string software = String.Format("{0}  アリーナクライアント バージョン: {1}", ApplicationConstants.APP_NAME, ApplicationConstants.VERSION);
            AppendToChatTextBoxDelegate(software, Color.DarkGreen, null);
            AppendToChatTextBoxDelegate("プロトコル: " + Protocol1Constants.PROTOCOL_NUMBER, Color.DarkGreen, null);
            ThreadPool.QueueUserWorkItem(new WaitCallback(PendingLogPollingLoop));
        }