Exemple #1
0
        static void OnMessage(object sender, MessageEventArgs args)
        {
            Console.WriteLine("Ответ получен: тип=" + (int)args.Message.Type);
            switch (args.Message.Type)
            {
            case MessageTypes.AuthenticateResponse:
                Console.WriteLine("Status: " + (args.Message as AuthenticationResponseMessage).Status);
                Console.WriteLine("Token: " + (args.Message as AuthenticationResponseMessage).Token);
                Console.WriteLine("Message: " + (args.Message as AuthenticationResponseMessage).Message);
                Console.WriteLine();
                if (!(args.Message as AuthenticationResponseMessage).Token.IsEmpty())
                {
                    TOKEN = (args.Message as AuthenticationResponseMessage).Token;
                    Console.WriteLine(TOKEN);
                }
                break;

            case MessageTypes.Status:
                Console.WriteLine("Status: " + (args.Message as StatusMessage).Status);
                Console.WriteLine("Message: " + (args.Message as StatusMessage).Text);
                break;

            case MessageTypes.BookList:
                BookListMessage m = args.Message as BookListMessage;
                Console.WriteLine("Count: " + m.Books.Count);
                ID = m.Books[0].Id;
                Console.WriteLine("ID = " + ID);
                Console.WriteLine("ID's title: " + m.Books[0].Title);
                break;

            case MessageTypes.Book:
                BookMessage mm = args.Message as BookMessage;
                Console.WriteLine("Content of a book: " + Encoding.Default.GetString(mm.Content));
                break;
            }
        }
Exemple #2
0
 // Обработка сообщения со списком книг на сервере
 private void OnBookListMessage(BookListMessage bookList)
 {
     RemoteBooks = bookList.Books;
 }