public override async Task Effect(StateMachineEvent evt, Command parameter)
        {
            if (parameter != null)
            {
                var status = new Status(new InformationMessageHeader(), Status.ErrorSeverity.Fatal, Status.ErrorCode.InvalidState, $"Command {parameter.FourCc()} is invalid or not available in IDENTIFY state.");
                status.OffendingCommandOrMissingFeature.Value = parameter.FourCc();
                await Sender.SendMessage(status.ToMessage());
            }

            if (evt.InternalEvent != InternalEvent.DisconnectOccured)
            {
                var quit = new Quit(new InformationMessageHeader(), User.Sid);
                await Sender.SendMessage(quit.ToMessage());
            }

            await User.Close();
        }
Beispiel #2
0
        private async Task DisconnectUser(ITransaction tx, string disconnectingSid)
        {
            var sids = await Sids;
            var maybeData = await sids.TryGetValueAsync(tx, disconnectingSid);
            if (maybeData.HasValue && maybeData.Value.IsExposed)
            {
                var quitCommand = new Quit(new InformationMessageHeader(), disconnectingSid);
                await ForAllSids(
                    tx,
                    await Sids,
                    async sid =>
                    {
                        if (sid == disconnectingSid)
                        {
                            return;
                        }

                        await GetSender(sid).SendMessage(quitCommand.ToMessage());
                    });

                var nicks = await Nicks;
                await nicks.TryRemoveAsync(tx, maybeData.Value.Nick);

                await sids.TryRemoveAsync(tx, disconnectingSid);
            }
        }
 public override async Task ElseEffect(StateMachineEvent evt, Command parameter)
 {
     var quit = new Quit(new InformationMessageHeader(), _user.Sid);
     await Sender.SendMessage(quit.ToMessage());
     await _user.Close();
 }