コード例 #1
0
        public void HandleRng()
        {
            string[] rngParameters = currentResponse.Split(" ");
            string   sessionId     = rngParameters[1];

            string[] addressAndPort = rngParameters[2].Split(":");
            int      sbPort;
            string   sbAddress = addressAndPort[0];

            int.TryParse(addressAndPort[1], out sbPort);
            string         authString     = rngParameters[4];
            string         principalEmail = rngParameters[5];
            string         principalName  = rngParameters[6];
            int            conversationId = random.Next(1000, 9999);
            SBConversation conversation   = new SBConversation(this, Convert.ToString(conversationId));

            SbConversations.Add(conversation);
            SwitchboardConnection switchboardConnection = new SwitchboardConnection(sbAddress, sbPort, email, authString, UserInfo.DisplayName, principalName, principalEmail, sessionId)
            {
                KeepMessagingHistory = KeepMessagingHistoryInSwitchboard
            };

            _ = switchboardConnection.AnswerRNG();
            SwitchboardCreated?.Invoke(this, new SwitchboardEventArgs()
            {
                switchboard = switchboardConnection
            });
            switchboardConnection.FillMessageHistory();
        }
コード例 #2
0
        public async Task HandleXfr()
        {
            string[] xfrParameters  = currentResponse.Split(" ");
            string[] addressAndPort = xfrParameters[3].Split(":");
            string   sbAddress      = addressAndPort[0];
            int      sbPort;

            int.TryParse(addressAndPort[1], out sbPort);
            string authString = "";

            switch (MsnpVersion)
            {
            case "MSNP12":
                authString = xfrParameters.Last();
                break;

            case "MSNP15":
                authString = xfrParameters[5];
                break;

            default:
                throw new Exceptions.VersionNotSelectedException();
            }
            SwitchboardConnection switchboardConnection = new SwitchboardConnection(sbAddress, sbPort, email, authString, UserInfo.DisplayName)
            {
                KeepMessagingHistory = KeepMessagingHistoryInSwitchboard
            };
            await switchboardConnection.LoginToNewSwitchboardAsync();

            await switchboardConnection.InvitePrincipal(ContactToChat.Email, ContactToChat.DisplayName);

            SwitchboardCreated?.Invoke(this, new SwitchboardEventArgs()
            {
                switchboard = switchboardConnection
            });
            switchboardConnection.FillMessageHistory();
        }