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"; }); } }
void OnDisable() { StartBtn.onClick.RemoveListener(OnBtnClick); ServerSocketMgr.GetIns().OnClientConnect -= OnClientConnect; }
void Awake() { Ins = this; ServerSocketMgr.RegistRecMsg(Default.CMD_KB, () => new Cmd4RecKB()); ServerSocketMgr.RegistRecMsg(Default.CMD_MOUSE, () => new Cmd4RecMouse()); }
void OnEnable() { StartBtn.onClick.AddListener(OnBtnClick); ServerSocketMgr.GetIns().OnClientConnect += OnClientConnect; }
public void CloseServer() { ServerSocketMgr.GetIns().Close(); }