using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using Protobuf; using Google.Protobuf; namespace KTGMGemClient { public class MasterSocket : BaseSocket { private static MasterSocket _Ins; public static MasterSocket Ins{ get{ return _Ins; } } /// /// Awake is called when the script instance is being loaded. /// void Awake() { _Ins=this; } public string MasterIp; public int MasterPort; /// /// 建立tcp链接 /// public void StartConnect() { Connect(MasterIp, MasterPort); StartCoroutine(StartRecv()); } protected override void OnConnected(bool connected) { Debug.Log("connected master:" + connected); EventCenter.Ins.BroadCast((int)KTGMGemClient.EventType.MasterSocketConnectResult, connected); } protected override void OnData(Opcode opcode, IMessage msg) { Debug.Log("on data: " + opcode + " msg:" + msg); SocketEvent.Ins.BroadCast((int)opcode, msg); } public void SetTestData(Opcode opcode, IMessage msg){ CommonDebugHelper.Debug("开始使用测试假数据"); OnData(opcode,msg); } /// /// Callback sent to all game objects before the application is quit. /// void OnApplicationQuit() { Close(); } } }