Exemplo n.º 1
0
    void OnBtnClick()
    {
        if (ServerMgr.Ins.BeServerConnect())
        {
            ServerMgr.Ins.CloseServer();

            StartBtnText.text = "start";
        }
        else
        {
            string _ip   = "";
            int    _port = 0;

            if (!IPInputField.text.Equals("nil"))
            {
                _ip   = IPInputField.text;
                _port = int.Parse(PortInputField.text);
            }
            else
            {
                _ip   = IPDropdown.captionText.text;
                _port = int.Parse(PortInputField.text);
            }

            ServerSocketMgr.GetIns().SetIPPort(_ip, _port);

            ServerSocketMgr.GetIns().Start(() =>
            {
                StartBtnText.text = "stop";
            });
        }
    }
Exemplo n.º 2
0
 void OnDisable()
 {
     StartBtn.onClick.RemoveListener(OnBtnClick);
     ServerSocketMgr.GetIns().OnClientConnect -= OnClientConnect;
 }
Exemplo n.º 3
0
 void Awake()
 {
     Ins = this;
     ServerSocketMgr.RegistRecMsg(Default.CMD_KB, () => new Cmd4RecKB());
     ServerSocketMgr.RegistRecMsg(Default.CMD_MOUSE, () => new Cmd4RecMouse());
 }
Exemplo n.º 4
0
 void OnEnable()
 {
     StartBtn.onClick.AddListener(OnBtnClick);
     ServerSocketMgr.GetIns().OnClientConnect += OnClientConnect;
 }
Exemplo n.º 5
0
 public void CloseServer()
 {
     ServerSocketMgr.GetIns().Close();
 }