Esempio n. 1
0
        private void MessageSorter(byte[] buffer, int start, int length, Socket clientSocket)
        {
            string            content  = Encoding.Default.GetString(buffer, 0, length);
            MessageDictionary messageD = new MessageDictionary(content);

            ShowMessage("从" + clientSocket.RemoteEndPoint.ToString() + "接收消息:" + content + "\n");
            CommandType command = (CommandType)Enum.Parse(typeof(CommandType), messageD[MesKeyStr.CommandType]);

            switch (command)
            {
            case CommandType.Login:
            {
                LoginEvent?.Invoke(this, new LoginEventArgs()
                    {
                        UserID        = messageD[MesKeyStr.UserID],
                        PassWord      = messageD[MesKeyStr.PassWord],
                        ReceiveSocket = clientSocket
                    });

                break;
            }

            case CommandType.Logout:
            {
                LogoutEvent?.Invoke(this, new User(messageD[MesKeyStr.UserID], messageD[MesKeyStr.NickName]));
                break;
            }

            case CommandType.SignUp:
            {
                SignUpEvent?.Invoke(this, new SignUpEventArgs(clientSocket, messageD[MesKeyStr.NickName], messageD[MesKeyStr.PassWord]));
                break;
            }

            case CommandType.GroupMessage:
            {
                GroupMessageEvent?.Invoke(this, messageD);
                break;
            }

            case CommandType.PrivateMessage:
            {
                PrivateMessageEvent?.Invoke(this, messageD);
                break;
            }

            case CommandType.UserJoin:
            case CommandType.UserQuit:
            case CommandType.LoginResult:
            case CommandType.SignUpResult:
            case CommandType.ServerDisconnect:
            case CommandType.Remove:
            {
                ShowMessage("收到错误的消息类型!");
                throw new Exception("收到错误的消息类型!");
            }
            }
        }
Esempio n. 2
0
        private void Setup()
        {
            TextField streamIDText = this.Q <TextField>("StreamIDText");
            Button    submitButton = this.Q <Button>("SubmitButton");
            Button    logoutButton = this.Q <Button>("LogoutButton");

            submitButton.RegisterCallback <ClickEvent>(ev => OnSubmit.Invoke(streamIDText.text));
            logoutButton.RegisterCallback <ClickEvent>(ev => LogoutEvent.Invoke());
        }
        public Task Logout(LogoutRequest data)
        {
            var flowId      = HttpContext.Items["flowId"].ToString();
            var logoutEvent = new LogoutEvent {
                Token = data.Token
            };

            publishingRouter.Publish(Queues.Users, logoutEvent, flowId);
            return(Task.CompletedTask);
        }
Esempio n. 4
0
        private void SubscribeEvents()
        {
            events.Add(
                eventAggregator.GetEvent <LogoutEvent>(),
                eventAggregator.GetEvent <LogoutEvent>().Subscribe(() => LogoutEvent?.Invoke()));

            events.Add(
                eventAggregator.GetEvent <QuitApplicationEvent>(),
                eventAggregator.GetEvent <QuitApplicationEvent>().Subscribe(() => QuitApplicationEvent?.Invoke()));
        }
Esempio n. 5
0
 public void Handle(LogoutEvent message)
 {
     if (IsLoggedIn == true)
     {
         ActivateItem(IoC.Get <DashboardViewModel>());
     }
     else
     {
         Logout();
         NotifyOfPropertyChange(() => IsLoggedIn);
     }
 }
Esempio n. 6
0
 public Task <AsyncTaskResult> HandleAsync(LogoutEvent evnt)
 {
     return(TryUpdateRecordAsync(conn =>
     {
         return conn.UpdateAsync(new
         {
             LogoutTime = evnt.LogoutTime,
             OnlineTime = evnt.OnlineTime,
             Updateby = evnt.UserId,
             UpdateTime = evnt.Timestamp,
         }, new { Id = evnt.AggregateRootId, }, TableNameConstants.ConLogTable);
     }));
 }
Esempio n. 7
0
        public void Logout()
        {
            LoggedIn = false;
            Stop();
            CurrentStation = null;
            _playlist.ClearSongs();
            _playlist.ClearHistory();
            _playlist.Current = null;
            _pandora.Logout();
            Email    = string.Empty;
            Password = string.Empty;

            LogoutEvent?.Invoke(this);
            _cqman.SendStatusUpdate(QueryStatusValue.Disconnected);
        }
Esempio n. 8
0
 protected override void OnStateFinished()
 {
     base.OnStateFinished();
     if (State is WidgetLoginState)
     {
         if (Model.IsLogin)
         {
             LoginEvent.SafeRaise(new LoginEventData(Model.MarketAccessToken,
                                                     Model.MarketRefreshAccessToken, Model.LoggedUsername));
         }
     }
     if (State is WidgetLogoutState)
     {
         if (!Model.IsLogin)
         {
             LogoutEvent.SafeRaise();
         }
     }
 }
Esempio n. 9
0
 /// <summary>
 /// Naciśnięcie przycisku wylogowywania
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void LogoutButtonClicked(object sender, EventArgs e)
 {
     LogoutEvent?.Invoke(sender, e);
 }
        public static void ImportLogs(string characterName)
        {
            var characterPath           = Path.Combine(App.DataDirectory, characterName);
            var slimcatPath             = Path.Combine(slimCatRoaming, characterName);
            var eventSerializerSettings = new JsonSerializerSettings {
                Converters          = new JsonConverter[] { new LogManager.CharacterConverter(null), new LogManager.ChannelMemberConverter(null), new LogManager.ChannelConverter() },
                TypeNameHandling    = TypeNameHandling.Auto,
                SerializationBinder = new LogManager.EventSerializationBinder()
            };
            var serializer = new MessageSerializer(null);

            foreach (var dir in Directory.EnumerateDirectories(slimcatPath))
            {
                var name  = Path.GetFileName(dir);
                var files = Directory.GetFiles(dir, "*.txt").Select(x => {
                    try {
                        var date = Path.GetFileNameWithoutExtension(x).Split('-').Select(int.Parse).ToArray();
                        return(new { Name = x, Date = new DateTime(date[2], date[0], date[1]) });
                    } catch {
                        return(null);
                    }
                }).Where(x => x != null).OrderBy(x => x.Date);
                if (name == "!Notifications")
                {
                    var events = new StreamWriter(Path.Combine(characterPath, "EventLog"));
                    foreach (var file in files)
                    {
                        foreach (var line in GetLogEntries(File.ReadLines(file.Name), eventRegex))
                        {
                            try {
                                Match match;
                                Event e = null;

                                DateTime GetTime()
                                {
                                    var time = match.Groups[1].Value;

                                    return(file.Date.AddMinutes(int.Parse(time.Substring(0, 2)) * 60 + int.Parse(time.Substring(3))));
                                }

                                if ((match = statusRegex.Match(line)).Success)
                                {
                                    var status = match.Groups[4].Success ? match.Groups[4].Value.ToEnum <StatusEnum>() : StatusEnum.Online;
                                    e = new StatusEvent(new Character(match.Groups[2].Value), status, match.Groups[6].Value, GetTime());
                                }
                                else if ((match = loginRegex.Match(line)).Success)
                                {
                                    e = new LoginEvent(new Character(match.Groups[2].Value), GetTime());
                                }
                                else if ((match = logoutRegex.Match(line)).Success)
                                {
                                    e = new LogoutEvent(new Character(match.Groups[2].Value), GetTime());
                                }
                                else if ((match = joinRegex.Match(line)).Success)
                                {
                                    e = new ChannelJoinEvent(new Channel(null, match.Groups[3].Value, null), new Channel.Member(new Character(match.Groups[2].Value)), GetTime());
                                }
                                else if ((match = leaveRegex.Match(line)).Success)
                                {
                                    e = new ChannelLeaveEvent(new Channel(null, match.Groups[3].Value, null), new Channel.Member(new Character(match.Groups[2].Value)), GetTime());
                                }
                                else if ((match = descriptionRegex.Match(line)).Success)
                                {
                                    continue;
                                }
                                else if ((match = opChangeRegex.Match(line)).Success)
                                {
                                    continue;
                                }
                                else if ((match = openRegex.Match(line)).Success)
                                {
                                    continue;
                                }
                                else if ((match = listRegex.Match(line)).Success)
                                {
                                    continue;
                                }
                                else if ((match = friendRegex.Match(line)).Success)
                                {
                                    continue;
                                }
                                else if ((match = kickRegex.Match(line)).Success)
                                {
                                    continue;
                                }
                                else if ((match = noteRegex.Match(line)).Success)
                                {
                                    e = new NoteEvent(new Character(match.Groups[2].Value), null, match.Groups[3].Value, GetTime());
                                }
                                else if ((match = broadcastRegex.Match(line)).Success)
                                {
                                    e = new BroadcastEvent(new Character(match.Groups[2].Value), match.Groups[3].Value, GetTime());
                                }
                                else if ((match = mentionRegex.Match(line)).Success)
                                {
                                    var time = GetTime();
                                    e = new MentionEvent(new Channel(null, match.Groups[4].Value, null),
                                                         new Message(Message.Type.Message, new Character(match.Groups[2].Value), time, match.Groups[5].Value), GetTime());
                                }
                                else if ((match = inviteRegex.Match(line)).Success)
                                {
                                    e = new InviteEvent(new Character(match.Groups[2].Value), new ChannelListItem(match.Groups[4].Value, match.Groups[3].Value, 0), GetTime());
                                }
                                if (e != null)
                                {
                                    events.WriteLine(JsonConvert.SerializeObject(e, typeof(Event), Formatting.None, eventSerializerSettings));
                                }
                            } catch {}
                        }
                    }
                    events.Dispose();
                    continue;
                }
                Stream logs = null, ads = null, logsIndex = null, adsIndex = null;
                var    parenIndex = name.IndexOf('(');
                var    logDir     = Path.Combine(characterPath, parenIndex != -1 ? $"#{name.Substring(parenIndex + 1, name.Length - parenIndex - 2)}" :
                                                 officialChannels.Contains(name) ? $"#{name}" : name);
                if (Directory.Exists(logDir))
                {
                    continue;
                }

                Directory.CreateDirectory(logDir);
                foreach (var file in files)
                {
                    var logsIndexed = false;
                    var adsIndexed  = false;
                    foreach (var line in GetLogEntries(File.ReadLines(file.Name), logRegex))
                    {
                        try {
                            var    index = 0;
                            var    type  = Message.Type.Message;
                            string sender;
                            if (line.StartsWith("Ad at"))
                            {
                                type   = Message.Type.Ad;
                                index += 6;
                            }
                            var h = int.Parse(line.Substring(index + 1, 2));
                            var m = int.Parse(line.Substring(index + 4, 2));
                            index += 8;
                            var text = "";
                            if (type == Message.Type.Ad)
                            {
                                var end = line.LastIndexOf("~By ");
                                if (end != -1)
                                {
                                    text   = line.Substring(index, end - index);
                                    sender = line.Substring(end + 4);
                                }
                                else
                                {
                                    sender = characterRegex.Match(line, index, Math.Min(20, line.Length - index)).Groups[1].Value;
                                    index += sender.Length;
                                    text   = index < line.Length ? line.Substring(index) : "";
                                }
                            }
                            else
                            {
                                if (line[index] == '[')
                                {
                                    type = Message.Type.Roll;
                                    var end = line.IndexOf('[', index);
                                    sender = line.Substring(index, end - index);
                                }
                                else
                                {
                                    if (index + characterName.Length <= line.Length && line.Substring(index, characterName.Length) == characterName)
                                    {
                                        sender = characterName;
                                    }
                                    else if (index + name.Length <= line.Length && line.Substring(index, name.Length) == name)
                                    {
                                        sender = name;
                                    }
                                    else
                                    {
                                        sender = characterRegex.Match(line, index, Math.Min(20, line.Length - index)).Groups[1].Value;
                                    }
                                    index += sender.Length;
                                    if (index < line.Length)
                                    {
                                        if (line[index] == ':')
                                        {
                                            index += 1;
                                            if (index < line.Length && line[index] == ' ')
                                            {
                                                index += 1;
                                            }
                                        }
                                        else
                                        {
                                            type = Message.Type.Action;
                                        }
                                    }
                                }
                                text += index < line.Length ? line.Substring(index) : "";
                            }
                            var stream = type == Message.Type.Ad ? (ads ?? (ads = File.OpenWrite(Path.Combine(logDir, "Ads")))) :
                                         (logs ?? (logs = File.OpenWrite(Path.Combine(logDir, "Logs"))));
                            if (type == Message.Type.Ad)
                            {
                                if (!adsIndexed)
                                {
                                    serializer.WriteIndex(adsIndex ?? (adsIndex = File.OpenWrite(Path.Combine(logDir, "Ads.idx"))), file.Date, stream.Position);
                                    adsIndexed = true;
                                }
                            }
                            else
                            {
                                if (!logsIndexed)
                                {
                                    serializer.WriteIndex(logsIndex ?? (logsIndex = File.OpenWrite(Path.Combine(logDir, "Logs.idx"))), file.Date, stream.Position);
                                    logsIndexed = true;
                                }
                            }
                            if (sender.Length > 20)
                            {
                                sender = sender.Substring(0, 20);
                            }
                            serializer.Write(stream, new Message(type, new Character(sender), file.Date.AddMinutes(h * 60 + m), text));
                        } catch { }
                    }
                }
                logs?.Dispose();
                ads?.Dispose();
                logsIndex?.Dispose();
                adsIndex?.Dispose();
            }
        }
Esempio n. 11
0
 public void Handle(LogoutEvent message)
 {
     // Aktywuje welcome view, gdy zostanie wywolany LogoutEvent
     ActivateItem(_welcomeVM);
 }
 public virtual void onPlayerLogout(LogoutEvent Event)
 {
 }
Esempio n. 13
0
 public void Handle(LogoutEvent logout)
 {
     ActivateItem(new LoginViewModel());
 }
Esempio n. 14
0
        private void OnLogoutCallback(LogoutRequest.Response result, LogoutRequest.RequestParams request)
        {
            LogoutEvent.SafeRaise();

            ApplyState <BasicWidgetLoginFormState>();
        }
Esempio n. 15
0
 private void logOutToolStripMenuItem_Click(object sender, EventArgs e)
 {
     service.Logut();
     service.UnSubScribeAll();
     LogoutEvent?.Invoke(this, e);
 }
        public static void syncPlayers()
        {
            bool flag = false;
            for (int i = 0; i < 255; i++)
            {
                int num = 0;
                if (Main.player[i].active)
                {
                    num = 1;
                }
                if (Netplay.serverSock[i].state == 10)
                {
                    if (Main.autoShutdown && !flag)
                    {
                        string text = Netplay.serverSock[i].tcpClient.Client.RemoteEndPoint.ToString();
                        string a = text;
                        for (int j = 0; j < text.Length; j++)
                        {
                            if (text.Substring(j, 1) == ":")
                            {
                                a = text.Substring(0, j);
                            }
                        }
                        if (a == "127.0.0.1")
                        {
                            flag = true;
                        }
                    }
                    NetMessage.SendData(14, -1, i, "", i, (float)num, 0f, 0f);
                    NetMessage.SendData(13, -1, i, "", i, 0f, 0f, 0f);
                    NetMessage.SendData(16, -1, i, "", i, 0f, 0f, 0f);
                    NetMessage.SendData(30, -1, i, "", i, 0f, 0f, 0f);
                    NetMessage.SendData(45, -1, i, "", i, 0f, 0f, 0f);
                    NetMessage.SendData(42, -1, i, "", i, 0f, 0f, 0f);
                    NetMessage.SendData(4, -1, i, Main.player[i].name, i, 0f, 0f, 0f);
                    for (int k = 0; k < 44; k++)
                    {
                        NetMessage.SendData(5, -1, i, Main.player[i].inventory[k].name, i, (float)k, 0f, 0f);
                    }
                    NetMessage.SendData(5, -1, i, Main.player[i].armor[0].name, i, 44f, 0f, 0f);
                    NetMessage.SendData(5, -1, i, Main.player[i].armor[1].name, i, 45f, 0f, 0f);
                    NetMessage.SendData(5, -1, i, Main.player[i].armor[2].name, i, 46f, 0f, 0f);
                    NetMessage.SendData(5, -1, i, Main.player[i].armor[3].name, i, 47f, 0f, 0f);
                    NetMessage.SendData(5, -1, i, Main.player[i].armor[4].name, i, 48f, 0f, 0f);
                    NetMessage.SendData(5, -1, i, Main.player[i].armor[5].name, i, 49f, 0f, 0f);
                    NetMessage.SendData(5, -1, i, Main.player[i].armor[6].name, i, 50f, 0f, 0f);
                    NetMessage.SendData(5, -1, i, Main.player[i].armor[7].name, i, 51f, 0f, 0f);
                    if (!Netplay.serverSock[i].announced)
                    {
                        Netplay.serverSock[i].announced = true;
                        NetMessage.SendData(25, -1, i, Main.player[i].name + " has joined.", 255, 255f, 240f, 20f);
                        if (Main.dedServ)
                        {
                            Program.tConsole.WriteLine(Main.player[i].name + " has joined.");

                            LoginEvent Event = new LoginEvent();
                            Event.setSocket(Netplay.serverSock[i]);
                            Event.setSender(Main.player[i]);
                            Program.server.getPluginManager().processHook(Plugin.Hooks.PLAYER_LOGIN, Event);
                        }
                    }
                }
                else
                {
                    NetMessage.SendData(14, -1, i, "", i, (float)num, 0f, 0f);
                    if (Netplay.serverSock[i].announced)
                    {
                        Netplay.serverSock[i].announced = false;
                        NetMessage.SendData(25, -1, i, Netplay.serverSock[i].oldName + " has left.", 255, 255f, 240f, 20f);
                        if (Main.dedServ)
                        {
                            Program.tConsole.WriteLine(Netplay.serverSock[i].oldName + " has left.");

                            LogoutEvent Event = new LogoutEvent();
                            Event.setSocket(Netplay.serverSock[i]);
                            Event.setSender(Main.player[i]);
                            Program.server.getPluginManager().processHook(Plugin.Hooks.PLAYER_LOGOUT, Event);
                        }
                    }
                }
            }
            if (Main.autoShutdown && !flag)
            {
                Commands.Commands.SaveAll();
                Netplay.disconnect = true;
            }
        }
Esempio n. 17
0
 private void OnLogoutClicked(object sender, EventArgs arguments)
 {
     _wifiObserver.StopListening();
     LogoutEvent?.Invoke(sender, arguments);
 }
 private void OnLogout(LogoutEvent e)
 {
     Username = string.Empty;
 }
 public void RaiseLogoutEvent()
 {
     LogoutEvent?.Invoke(this, EventArgs.Empty);
 }
 public Task Logout(MessageContext context, LogoutEvent inputEvent)
 {
     usersRepository.RemoveSession(inputEvent.Token);
     return(Task.CompletedTask);
 }
Esempio n. 21
0
 internal void FireLogoutEvent() => LogoutEvent?.Invoke(this, new LoginEventArgs()
 {
 });
 private void OnLogout(LogoutEvent e)
 {
     IsLoggedIn = false;
 }
        /// <summary>
        /// Shows the authenticated menu.
        /// </summary>
        /// <param name="deviceName">Name of the device.</param>
        /// <param name="uploading">if set to <c>true</c> [uploading].</param>
        /// <param name="callback">The callback.</param>
        public void ShowAuthenticatedMenu(string deviceName, bool uploading, LogoutEvent callback)
        {
            Menu.Items.Clear();
            AddMenu(string.Format("{0}", deviceName), 0, Resources.device, Device_Click);

            if (!uploading)
            {
                AddMenu("Scan Music", 1, Resources.upload, Load_Click);
            }
            else
            {
                Menu.Items.Insert(1, new ToolStripMenuItem()
                {
                    Text = "Scanning...",
                    Enabled = false
                });
            }

            AddMenu("Logout", 2, Resources._out, Logout_Click);
            this.callback = callback;

            Menu.Items.Add(exitToolStrip);
        }
Esempio n. 24
0
 private void MainView_FormClosed(object sender, FormClosedEventArgs e)
 {
     service.Logut();
     service.UnSubScribeAll();
     LogoutEvent?.Invoke(this, e);
 }