//初始化网络组件 public void InitNetComponent() { if (_netComponentInitted) { return; } Log.info(">> 初始化网络组件!"); _netComponentInitted = true; //------------- 定义GameSvr连接 ----------- //协议 _gameSvrProtoUtil = new ProtoUtil(); //连接 _gameSvrConnect = NetworkConnect.Create("GameSvrNet", Core.SystemPluginRoot, _gameSvrProtoUtil); _gameSvrConnect.RegisterHandle(this.SendHeartBeadPkg, this.ChkSendPkg, this.ChkRecvPkg, this.PkgError); //TODO 后续可以定义 BattleSvr 连接,并添加到管理列表 //网络状态监控 _networkMonitor = NetworkMonitor.Create(Core.SystemPluginRoot); //降定义的svr连接加入到网络状态监控器中 _networkMonitor.AddServerNet(_gameSvrConnect); }
/// <summary> /// 注册引用关系 /// </summary> /// <param name="m_netConnector"></param> /// <param name="m_protoUtil"></param> /// <param name="heartBeatHandler"></param> public void RegisterNetConnector(NetworkConnect m_netConnector, ProtoUtil m_protoUtil, DelegateEnums.NoneParam heartBeatHandler) { _netConnector = m_netConnector; _protoUtil = m_protoUtil; _heartBeatHandler += heartBeatHandler; Reset(); }
void Start() { network = GameObject.Find("/GameManager").GetComponent <NetworkConnect>(); sp = transform.GetComponentsInChildren <stopSelf>(); for (int i = 0; i < 5; i++) { canmove [i] = false; } }
public void InitSmallGame() { SmallGameTipsManager.timer = 1000; smallTotalWin = 0; SmallGame.canSelect = true; smallGameTimesLabel.text = valueOfTime.ToString(); networkConnect = GameObject.Find("/GameManager").GetComponent <NetworkConnect>(); smallGameTipsManager = GameObject.FindGameObjectWithTag("SgHelp").GetComponent <SmallGameTipsManager>(); smallGameTipsManager.CheckTip(); }
/// <summary> /// 创建一个客户端网络连接 /// </summary> /// <returns></returns> public static NetworkConnect Create(string svrName, Transform pluginRoot, ProtoUtil protoUtil) { if (_root == null) { _root = pluginRoot; } GameObject go = new GameObject(); go.name = svrName; go.transform.parent = _root; NetworkConnect server = go.AddComponent <NetworkConnect>(); server.Init(protoUtil); return(server); }
public void Dispose() { if (_gameSvrProtoUtil != null) { _gameSvrProtoUtil.Clear(); } if (_gameSvrConnect != null) { _gameSvrConnect.UnRegisterHandle(this.SendHeartBeadPkg, this.ChkSendPkg, this.ChkRecvPkg, this.PkgError); } _gameSvrConnect = null; _gameSvrProtoUtil = null; _networkMonitor = null; base.Dispose(); }
static async Task Main(string[] args) { //Listando redes var networkConn = new NetworkConnect(); var allNetworks = await networkConn.NetworkWifi.GetNetworksAsync(); var myNetwork = allNetworks.Where(e => e.SSID == "MySSID").FirstOrDefault(); networkConn.NetworkWifi.ConnectNetworkAsync(myNetwork, "MyPassword"); if (networkConn.NetworkWifi.IsConnected.Result) { Console.WriteLine("Conected"); } else { foreach (var err in networkConn.NetworkWifi.GetErrors()) { Console.WriteLine(err); } } }
public void Initialize(NetworkConnect owner) { _owner = owner; }
private void RaiseConnect(object sender, NetworkConnectEventArgs e) { NetworkConnect?.Invoke(sender, e); }
/// <summary> /// 反注册 /// </summary> /// <param name="heartBeatHandler"></param> public void UnRegisterNetConnect(DelegateEnums.NoneParam heartBeatHandler) { _netConnector = null; _protoUtil = null; _heartBeatHandler -= heartBeatHandler; }
public void UnRegisterNetConnector(DelegateEnums.NoneParam heartBeatHandler) { this._onHeartBeatHandler -= heartBeatHandler; this._netConnect = null; }
public void RegisterNetConnector(NetworkConnect netConnector, DelegateEnums.NoneParam heartBeatHandler) { this._onHeartBeatHandler += heartBeatHandler; this._netConnect = netConnector; }
public void AddServerNet(NetworkConnect svr) { _svrList.Add(svr); }