/// <summary> /// pbc/pblua函数回调 /// </summary> /// <param name="func"></param> public static void OnCallLuaFunc(LuaByteBuffer data, LuaFunction func) { if (func != null) { func.Call(data); } Util.LogWarning("OnCallLuaFunc length:>>" + data.buffer.Length); }
/// <summary> /// cjson函数回调 /// </summary> /// <param name="data"></param> /// <param name="func"></param> public static void OnJsonCallFunc(string data, LuaFunction func) { Util.LogWarning("OnJsonCallback data:>>" + data + " lenght:>>" + data.Length); if (func != null) { func.Call(data); } }
/// <summary> /// 发送SOCKET消息, /// </summary> /// <param name="cmd"></param> /// <param name="action"></param> public void SendMessage(CitrusNet.NetCommand cmd, Action <CitrusNet.NetCommand> action = null) { this.Call_Ex("route,session", cmd, (header, args) => { if (header.Errno != 0) { Util.LogWarning($"errno: {header.Errno}, error: {header.Error}, reply: {args}"); return; } if (action != null) { action(args); } }); }
//消息处理 public override void OnMessage(Channel channel, NetPacket packet) { var phobosPacket = (PhobosPacket)packet; Util.LogWarning($"--< Receive Message >-- msg: {phobosPacket.Command} ProtoID: {phobosPacket.ProtoID} Errno: {phobosPacket.Head.Errno} error: {phobosPacket.Head.Error}"); if (phobosPacket.Head.Errno != (int)errors.proto.E_Code.E_Ok) { return; } if (phobosPacket.Head.RequestId != 0) { // 处理请求回应消息 HandleRequest(phobosPacket); } else { // 处理服务器推送消息 HandlePush_Ex(phobosPacket); } }
/// <summary> /// 初始化 /// </summary> public void initialize(Action func) { if (AppConst.ExampleMode) { //------------------------------------Shared-------------------------------------- string uri = Util.DataPath + "shared" + AppConst.ExtName; Util.LogWarning("LoadFile::>> " + uri); shared = AssetBundle.LoadFromFile(uri); #if UNITY_5 shared.LoadAsset("Dialog", typeof(GameObject)); #else shared.Load("Dialog", typeof(GameObject)); #endif } if (func != null) { func(); //资源初始化完成,回调游戏管理器,执行后续操作 } }
//发送接口 private void Call_Ex(string metas, CitrusNet.NetCommand args, CitrusNet.Phobos.RpcCallback <CitrusNet.NetCommand> callback) { Util.LogWarning($"--< Send Message >-- msg: {args} route: {GetValue("route", args)}"); this.Call(metas, args, callback); }
/// <summary> /// 初始化面板 /// </summary> public void OnInit(AssetBundle bundle, string text = null) { this.data = text; //初始化附加参数 this.bundle = bundle; //初始化 Util.LogWarning("OnInit---->>>" + name + " text:>" + text); }