public void SendMessage(Message msg) { try { if (!_isDisconnected) { if (msg.Type == MessageType.Build) { BuildMessage bm = (BuildMessage)msg; InfoLog.WriteInfo("Sending build message to player: " + this.Id, EPrefix.Test); InfoLog.WriteInfo("Buildmessage data: " + bm.ToString(), EPrefix.Test); } if (msg.Type == MessageType.BuildUnitMessage) { BuildUnitMessage bum = (BuildUnitMessage)msg; InfoLog.WriteInfo("Sending build unit message to player: " + this.Id, EPrefix.Test); InfoLog.WriteInfo("BuildUnitMessage data: " + bum.ToString(), EPrefix.Test); } msg.Serialize(_writeStream); _writeStream.Flush(); if (msg.Type == MessageType.DoTurn) { _tac.Unset(this.Login); } } } catch (Exception ex) { InfoLog.WriteException(ex); ExecuteOnConnectionLost(); } }
public void TypeMessageConstructorTest() { BuildMessageType type; BuildMessage msg; String message; // // Prepare the test. // type = BuildMessageType.Error; message = "This is a message"; // // Run the test. // msg = new BuildMessage(type, message); // // Verify the test. // Assert.AreEqual(type, msg.Type); Assert.AreEqual(type.ToString() + ": " + message, msg.ToString()); }