Beispiel #1
0
        public void RemoveClientActor(global::System.UInt64 actorId, global::Fenix.Common.DisconnectReason reason, global::System.Action <global::Fenix.Common.DefaultErrCode> callback)
        {
            var toHostId = Global.IdManager.GetHostIdByActorId(this.toActorId, this.isClient);

            if (this.FromHostId == toHostId)
            {
                var protoCode = OpCode.REMOVE_CLIENT_ACTOR_REQ;
                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[] { actorId, reason, callback, context });
                }
                else
                {
                    Global.Host.GetActor(this.toActorId).CallMethodWithParams(protoCode, new object[] { actorId, reason, callback });
                }
                return;
            }
            Task.Run(() => {
                var msg = new RemoveClientActorReq()
                {
                    actorId = actorId,
                    reason  = reason
                };
                var cb = new Action <byte[]>((cbData) => {
                    var cbMsg = cbData == null?new RemoveClientActorReq.Callback():RpcUtil.Deserialize <RemoveClientActorReq.Callback>(cbData);
                    callback?.Invoke(cbMsg.code);
                });
                this.CallRemoteMethod(OpCode.REMOVE_CLIENT_ACTOR_REQ, msg, cb);
            });
        }
Beispiel #2
0
        public void OnBeforeDisconnect(global::Fenix.Common.DisconnectReason reason, global::System.Action callback)
        {
            var toHostId = Global.IdManager.GetHostIdByActorId(this.toActorId, this.isClient);

            if (this.FromHostId == toHostId)
            {
                var protoCode = OpCode.ON_BEFORE_DISCONNECT_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[] { reason, callback, context });
                }
                else
                {
                    Global.Host.GetActor(this.toActorId).CallMethodWithParams(protoCode, new object[] { reason, callback });
                }
                return;
            }
            Task.Run(() => {
                var msg = new OnBeforeDisconnectNtf()
                {
                    reason = reason
                };
                var cb = new Action <byte[]>((cbData) => {
                    var cbMsg = cbData == null?new OnBeforeDisconnectNtf.Callback():RpcUtil.Deserialize <OnBeforeDisconnectNtf.Callback>(cbData);
                    callback?.Invoke();
                });
                this.CallRemoteMethod(OpCode.ON_BEFORE_DISCONNECT_NTF, msg, cb);
            });
        }
Beispiel #3
0
        public void CLIENT_API_NATIVE__Fenix__Host__on_before_disconnect(global::Fenix.Common.DisconnectReason reason, global::System.Action callback, RpcContext context)
        {
#if ENABLE_IL2CPP || !DEBUG || RUNTIME
            this.OnBeforeDisconnect(reason, callback, context);
            on_before_disconnect?.Invoke(reason, callback);
#else
            self.OnBeforeDisconnect(reason, callback, context);
            on_before_disconnect?.Invoke(reason, callback);
#endif
        }
Beispiel #4
0
        public async Task <OnBeforeDisconnectNtf.Callback> OnBeforeDisconnectAsync(global::Fenix.Common.DisconnectReason reason, global::System.Action callback = null)
        {
            var t        = new TaskCompletionSource <OnBeforeDisconnectNtf.Callback>();
            var toHostId = Global.IdManager.GetHostIdByActorId(this.toActorId, this.isClient);

            if (this.FromHostId == toHostId)
            {
                global::System.Action _cb = () =>
                {
                    var cbMsg = new OnBeforeDisconnectNtf.Callback();

                    callback?.Invoke();
                    t.TrySetResult(cbMsg);
                };
                var protoCode = OpCode.ON_BEFORE_DISCONNECT_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[] { reason, _cb, context });
                }
                else
                {
                    Global.Host.GetActor(this.toActorId).CallMethodWithParams(protoCode, new object[] { reason, _cb });
                }
            }
            else
            {
                Action <OnBeforeDisconnectNtf.Callback> _cb = (cbMsg) =>
                {
                    callback?.Invoke();
                    t.TrySetResult(cbMsg);
                };
                await Task.Run(() => {
                    var msg = new OnBeforeDisconnectNtf()
                    {
                        reason = reason
                    };
                    var cb = new Action <byte[]>((cbData) => {
                        var cbMsg = cbData == null ? new OnBeforeDisconnectNtf.Callback() : RpcUtil.Deserialize <OnBeforeDisconnectNtf.Callback>(cbData);
                        _cb?.Invoke(cbMsg);
                    });
                    this.CallRemoteMethod(OpCode.ON_BEFORE_DISCONNECT_NTF, msg, cb);
                });
            }
            return(await t.Task);
        }
Beispiel #5
0
        public async Task <RemoveClientActorReq.Callback> RemoveClientActorAsync(global::System.UInt64 actorId, global::Fenix.Common.DisconnectReason reason, global::System.Action <global::Fenix.Common.DefaultErrCode> callback = null)
#endif
        {
#if FENIX_CODEGEN
#if !RUNTIME
            var t = new TaskCompletionSource <dynamic>();
#else
            var t = new TaskCompletionSource <RemoveClientActorReq.Callback>();
#endif
#else
            var t        = new TaskCompletionSource <RemoveClientActorReq.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 RemoveClientActorReq.Callback();
                    cbMsg.code = code;
                    callback?.Invoke(cbMsg.code);
                    t.TrySetResult(cbMsg);
                };
                var protoCode = OpCode.REMOVE_CLIENT_ACTOR_REQ;
                if (Math.Abs(protoCode) < OpCode.CALL_ACTOR_METHOD)
                {
                    var peer    = Global.NetManager.GetRemotePeerById(this.FromHostId, this.NetType);
                    var context = new RpcContext(null, peer);
                    Global.Host.CallMethodWithParams(protoCode, new object[] { actorId, reason, _cb, context });
                }
                else
                {
                    Global.Host.GetActor(this.toActorId).CallMethodWithParams(protoCode, new object[] { actorId, reason, _cb });
                }
            }
            else
            {
                Action <RemoveClientActorReq.Callback> _cb = (cbMsg) =>
                {
                    callback?.Invoke(cbMsg.code);
                    t.TrySetResult(cbMsg);
                };
                await Task.Run(() => {
                    var msg = new RemoveClientActorReq()
                    {
                        actorId = actorId,
                        reason  = reason
                    };
                    var cb = new Action <byte[]>((cbData) => {
                        var cbMsg = cbData == null ? new RemoveClientActorReq.Callback() : global::Fenix.Common.Utils.RpcUtil.Deserialize <RemoveClientActorReq.Callback>(cbData);
                        _cb?.Invoke(cbMsg);
                    });
                    this.CallRemoteMethod(OpCode.REMOVE_CLIENT_ACTOR_REQ, msg, cb);
                });
            }
#endif
            return(await t.Task);
        }
Beispiel #6
0
        public void SERVER_API_NATIVE__Fenix__Host__remove_client_actor(global::System.UInt64 actorId, global::Fenix.Common.DisconnectReason reason, global::System.Action <global::Fenix.Common.DefaultErrCode> callback, RpcContext context)
        {
#if ENABLE_IL2CPP || !DEBUG || RUNTIME
            this.RemoveClientActor(actorId, reason, callback, context);
#else
            self.RemoveClientActor(actorId, reason, callback, context);
#endif
        }
Beispiel #7
0
 public void CLIENT_API_NATIVE__Fenix__Host__on_before_disconnect(global::Fenix.Common.DisconnectReason reason, global::System.Action callback, RpcContext context)
 {
     this.OnBeforeDisconnect(reason, callback, context);
     on_before_disconnect?.Invoke(reason, callback);
 }
Beispiel #8
0
 public void SERVER_API_NATIVE__Fenix__Host__remove_client_actor(global::System.UInt64 actorId, global::Fenix.Common.DisconnectReason reason, global::System.Action <global::Fenix.Common.DefaultErrCode> callback, RpcContext context)
 {
     this.RemoveClientActor(actorId, reason, callback, context);
 }