本文整理汇总了C#中CommandReader.GetReadObservable方法的典型用法代码示例。如果您正苦于以下问题:C# CommandReader.GetReadObservable方法的具体用法?C# CommandReader.GetReadObservable怎么用?C# CommandReader.GetReadObservable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CommandReader
的用法示例。
在下文中一共展示了CommandReader.GetReadObservable方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoginAsync
public async Task LoginAsync(UserStatus initialStatus = UserStatus.Online)
{
await @lock.WriterLockAsync();
try
{
if (IsLoggedIn)
return;
IConnection connection = null;
ConnectionStream stream = null;
CommandReader reader = null;
CommandWriter writer = null;
ResponseTracker responseTracker = null;
IConnectableObservable<Command> commands = null;
IDisposable commandsDisposable = null;
int transferCount = 0;
SocketEndPoint endPoint = SocketEndPoint.Parse("messenger.hotmail.com:1863");
string authTicket = null;
while (authTicket == null)
{
connection = new SocketConnection();
await connection.ConnectAsync(endPoint);
stream = new ConnectionStream(connection);
writer = new CommandWriter(stream);
reader = new CommandReader(stream, new Dictionary<string, Type> {
{ "VER", typeof(VersionCommand) },
{ "CVR", typeof(ClientVersionCommand) },
{ "USR", typeof(AuthenticateCommand) },
{ "XFR", typeof(TransferCommand) },
{ "SYN", typeof(SynchronizeCommand) },
{ "SBS", typeof(SbsCommand) },
{ "MSG", typeof(MessageCommand) },
{ "LST", typeof(UserCommand) },
{ "LSG", typeof(GroupCommand) },
{ "BPR", typeof(UserPropertyCommand) },
{ "BLP", typeof(PrivacySettingCommand) },
{ "GTC", typeof(PrivacySettingCommand) },
{ "CHG", typeof(ChangeStatusCommand) },
{ "UBX", typeof(BroadcastCommand) },
{ "PRP", typeof(LocalPropertyCommand) },
{ "NLN", typeof(UserOnlineCommand) },
{ "ILN", typeof(InitialUserOnlineCommand) },
{ "FLN", typeof(UserOfflineCommand) },
{ "UUX", typeof(SendBroadcastCommand) },
{ "NOT", typeof(NotificationCommand) },
{ "QNG", typeof(PingCommand) },
{ "CHL", typeof(ChallengeCommand) },
{ "ADC", typeof(AddContactCommand) },
{ "REM", typeof(RemoveContactCommand) },
{ "ADG", typeof(AddGroupCommand) },
{ "RMG", typeof(RemoveGroupCommand) },
{ "REG", typeof(RenameGroupCommand) },
{ "QRY", typeof(AcceptChallengeCommand) },
{ "RNG", typeof(RingCommand) },
{ "SBP", typeof(ChangeUserPropertyCommand) },
{ "IMS", typeof(EnableIMCommand) },
});
commands = reader.GetReadObservable().Publish();
responseTracker = new ResponseTracker(writer, commands);
commandsDisposable = commands.Connect();
var versionCommand = new VersionCommand("MSNP12");
var versionResponse = await responseTracker.GetResponseAsync<VersionCommand>(versionCommand, defaultTimeout);
if (versionResponse.Versions.Length == 0)
throw new ProtocolNotAcceptedException();
var clientVersionCommand = new ClientVersionCommand
{
LocaleId = "0x0409",
OsType = "winnt",
OsVersion = "5.0",
Architecture = "1386",
LibraryName = "MSMSGS",
ClientVersion = "5.0.0482",
ClientName = "WindowsMessenger",
LoginName = credentials.LoginName,
};
await responseTracker.GetResponseAsync<ClientVersionCommand>(clientVersionCommand, defaultTimeout);
var userCommand = new AuthenticateCommand("TWN", "I", credentials.LoginName);
var userResponse = await responseTracker.GetResponseAsync(userCommand, new Type[] { typeof(AuthenticateCommand), typeof(TransferCommand) }, defaultTimeout);
if (userResponse is AuthenticateCommand)
{
authTicket = (userResponse as AuthenticateCommand).Argument;
//.........这里部分代码省略.........