protected override void OnPeerConnected(IPeer peer) { try { // join game after connected if (game != null) { if (game.status == GameStatus.WaitToInitialize) { debugger.Log("Start initialize game."); game.Initialize().Wait(); debugger.Log("End initialize game."); } if (game.status == GameStatus.WaitToStart) { debugger.Log("Start game."); game.Start(); } } debugger.Log("Join game."); game.JoinAsync(peer, null) .ContinueWith((res) => OnPeerJoinResponse(peer, res.Result)); } catch (Exception e) { debugger.LogError(e); } }
public void ResetServer() { if (server == null) { //server = new UnityServer(debugger); ProcessServer ps = new ProcessServer(); ps.OnReceiveOutput += (sender, args) => { debugger.Log(args.Data); }; server = ps; } server.Reset(); }
public void Start() { debugger.Log("Launching server ... "); server.ConnectKey = ConnectKey; server.MaxPeers = MaxPeers; server.Start(Port); }
/// <summary> /// 打印 /// </summary> /// <param name="message">消息</param> /// <param name="color">颜色</param> public void Log(object message, string color = "white") { if (!HasLevel(DebugLevel.Normal)) { return; } debugger.Log(message, color); }
private void OnClientReceivePacketEvent(object obj, Reliability reliability) { GenericPacket packet = obj as GenericPacket; if (packet != null) { if (receivers.TryGetValue(packet.InstCode, out List <IPacketReceiver> receiverList)) { try { foreach (var receiver in receiverList) { receiver.Receive(packet.Data); } } catch (Exception e) { debugger.LogError(e.Message + e.StackTrace); } } if (actions.TryGetValue(packet.InstCode, out List <Action <object> > actionList)) { foreach (var action in actionList) { try { action.Invoke(packet.Data); } catch (Exception e) { debugger.Log(e.Message + e.StackTrace); } } } } else { debugger.Log("Packet is null."); } }
public void ExitAll(string msg = "", object arg = null) { // cancel all of queuing requests int queueingCount = CancelAllRequestFromList(ref joinQueuing, msg, arg); // cancel all of handling requests int handlingCount = CancelAllRequestFromList(ref joinHandling, msg, arg); int inGroupCount = peers.Count; // untrack current group from peers List <IPeer> inGroups = new List <IPeer>(peers.Values); // clear all peers peers.Clear(); foreach (var peer in inGroups) { peer.UntrackGroup(this); } debugger.Log($"Group[{GroupId}] exit all peers, queueing cancelled : {queueingCount}, handling cancelled : {handlingCount}, in group : {inGroupCount}"); }
/// <summary> /// 以同步的形式加载指定的资源 /// </summary> /// <param name="path">资源路径</param> protected override object InternalLoadSync(string path) { debugger.Log("LoaderAssetBundle : " + path); return("LoaderAssetBundle"); }
public void Log(object obj) { Debugger.Log(obj); }
public static void Log(byte[] bytes) { Debugger.Log(bytes); }
/// <summary> /// 以同步的形式加载指定的资源 /// </summary> /// <param name="path">资源路径</param> protected override object InternalLoadSync(string path) { debugger.Log("LoaderResourcesFolder : " + path); return("LoaderResourcesFolder"); }