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;
|
}
|
}
|
/// <summary>
|
/// Awake is called when the script instance is being loaded.
|
/// </summary>
|
void Awake()
|
{
|
_Ins=this;
|
}
|
public string MasterIp;
|
public int MasterPort;
|
|
/// <summary>
|
/// 建立tcp链接
|
/// </summary>
|
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);
|
}
|
|
/// <summary>
|
/// Callback sent to all game objects before the application is quit.
|
/// </summary>
|
void OnApplicationQuit()
|
{
|
Close();
|
}
|
}
|
}
|