private static void MessageReceived(Message message) { if (message is ChatMessage) Console.WriteLine(((ChatMessage)message).Text); else if (message is GameOverMessage) Console.WriteLine("Game Over, Player " + ((GameOverMessage)message).Winner + " has won with Points=" + ((GameOverMessage)message).Points); }
public static void AddMessage(string username, string text) { MongoDatabase db = new MongoClient("mongodb://*****:*****@ds061548.mongolab.com:61548/chat-db") .GetServer() .GetDatabase("chat-db"); var messagesCollection = db.GetCollection<Message>("messages"); var message = new Message { Date = DateTime.Now, Username = username, Text = text }; messagesCollection.Insert(message); }