Beispiel #1
0
        public void CLIENT_API_reconnect_server_actor(IMessage msg, Action <IMessage> cb, RpcContext context)
        {
            var _msg = (ReconnectServerActorNtf)msg;

            this.ReconnectServerActor(_msg.hostId, _msg.hostName, _msg.hostIP, _msg.hostPort, _msg.actorId, _msg.actorName, _msg.aTypeName, (code) =>
            {
                var cbMsg  = new ReconnectServerActorNtf.Callback();
                cbMsg.code = code;
                cb.Invoke(cbMsg);
            }, context);
        }
Beispiel #2
0
        public async Task <ReconnectServerActorNtf.Callback> ReconnectServerActorAsync(global::System.UInt64 hostId, global::System.String hostName, global::System.String hostIP, global::System.Int32 hostPort, global::System.UInt64 actorId, global::System.String actorName, global::System.String aTypeName, global::System.Action <global::Fenix.Common.DefaultErrCode> callback = null)
        {
            var t        = new TaskCompletionSource <ReconnectServerActorNtf.Callback>();
            var toHostId = Global.IdManager.GetHostIdByActorId(this.toActorId, this.isClient);

            if (this.FromHostId == toHostId)
            {
                global::System.Action <global::Fenix.Common.DefaultErrCode> _cb = (code) =>
                {
                    var cbMsg = new ReconnectServerActorNtf.Callback();
                    cbMsg.code = code;
                    callback?.Invoke(cbMsg.code);
                    t.TrySetResult(cbMsg);
                };
                var protoCode = OpCode.RECONNECT_SERVER_ACTOR_NTF;
                if (protoCode < OpCode.CALL_ACTOR_METHOD)
                {
                    var peer    = Global.NetManager.GetPeerById(this.FromHostId, this.NetType);
                    var context = new RpcContext(null, peer);
                    Global.Host.CallMethodWithParams(protoCode, new object[] { hostId, hostName, hostIP, hostPort, actorId, actorName, aTypeName, _cb, context });
                }
                else
                {
                    Global.Host.GetActor(this.toActorId).CallMethodWithParams(protoCode, new object[] { hostId, hostName, hostIP, hostPort, actorId, actorName, aTypeName, _cb });
                }
            }
            else
            {
                Action <ReconnectServerActorNtf.Callback> _cb = (cbMsg) =>
                {
                    callback?.Invoke(cbMsg.code);
                    t.TrySetResult(cbMsg);
                };
                await Task.Run(() => {
                    var msg = new ReconnectServerActorNtf()
                    {
                        hostId    = hostId,
                        hostName  = hostName,
                        hostIP    = hostIP,
                        hostPort  = hostPort,
                        actorId   = actorId,
                        actorName = actorName,
                        aTypeName = aTypeName
                    };
                    var cb = new Action <byte[]>((cbData) => {
                        var cbMsg = cbData == null ? new ReconnectServerActorNtf.Callback() : RpcUtil.Deserialize <ReconnectServerActorNtf.Callback>(cbData);
                        _cb?.Invoke(cbMsg);
                    });
                    this.CallRemoteMethod(OpCode.RECONNECT_SERVER_ACTOR_NTF, msg, cb);
                });
            }
            return(await t.Task);
        }
Beispiel #3
0
        public void CLIENT_API__Fenix__Host__reconnect_server_actor(IMessage msg, Action <IMessage> cb, RpcContext context)
        {
#if ENABLE_IL2CPP || !DEBUG || RUNTIME
            var _msg = (ReconnectServerActorNtf)msg;
            this.ReconnectServerActor(_msg.hostId, _msg.hostName, _msg.hostIP, _msg.hostPort, _msg.actorId, _msg.actorName, _msg.aTypeName, (code) =>
            {
                var cbMsg  = new ReconnectServerActorNtf.Callback();
                cbMsg.code = code;
                cb.Invoke(cbMsg);
            }, context);
#else
            dynamic _msg = msg;
            self.ReconnectServerActor(_msg.hostId, _msg.hostName, _msg.hostIP, _msg.hostPort, _msg.actorId, _msg.actorName, _msg.aTypeName, (global::System.Action <global::Fenix.Common.DefaultErrCode>)((code) =>
            {
                dynamic cbMsg = new ReconnectServerActorNtf.Callback();
                cbMsg.code    = code;
                cb.Invoke(cbMsg);
            }), context);
#endif
        }