public void TestCreateGameConv() { IPEndPoint ip = new IPEndPoint(IPAddress.Any, 0); CreateGameConv conv = ConversationFactory .Instance.CreateFromConversationType <CreateGameConv> (ip, null, null, null); conv._MinPlayers = 5; conv._MaxPlayers = 6; CreateGame msg = (CreateGame)conv.CreateFirstMessage(); Assert.AreEqual(msg.MaxPlayers, 6); Assert.AreEqual(msg.MinPlayers, 5); CommSubSystem.ConversationQueue queue = conv.MyQueue; queue.Enqueue(msg.Encode()); conv.Receive(); Assert.AreEqual(conv.Error, null); Assert.AreEqual(conv.incomingMsg, msg.Encode()); Assert.AreEqual(true, conv.ValidateEnvelope(msg)); }
public void TestCreateConversation() { MessageId msgid = new MessageId() { Pid = 7, Seq = 3 }; Message msg = new Message() { ConvId = msgid, MsgId = msgid, MessageType = TypeOfMessage.Ack }; IPEndPoint ip = new IPEndPoint(IPAddress.Any, 0); CreateGameConv conv = ConversationFactory .Instance.CreateFromMessage <CreateGameConv> (msg.Encode(), ip, null, null, null); Assert.AreEqual(conv.EndIP, ip); Assert.AreEqual(conv.ConvId, msgid); CreateGameConv conv2 = ConversationFactory .Instance.CreateFromConversationType <CreateGameConv> (ip, null, null, null); Assert.AreEqual(conv2.EndIP, ip); Assert.AreNotEqual(conv.ConvId, msgid); }
//where we would put the createGame stuff public void CreateGame() { IPEndPoint server = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 1024); CreateGameConv conv = ConversationFactory.Instance .CreateFromConversationType <CreateGameConv> (server, null, null, null); Thread convThread = new Thread(conv.Execute); convThread.Start(); }
public void CreateGame(int min, int max, string name) { //var parameters = new string[]{ min.ToString(), max.ToString(), name }; CreateGameConv conv = ConversationFactory.Instance .CreateFromConversationType <CreateGameConv> (server, null, CreateGamePostExecute, null); //using lambda operator to pass parameters as object conv._GameName = name; conv._MinPlayers = min; conv._MaxPlayers = max; conv._Player = Player; conv.Start(); }
private void CreateGameResponse(byte[] bytes, IPEndPoint refEp) { CreateGameConv conv = ConversationFactory.Instance .CreateFromMessage <CreateGameConv>(bytes, refEp, null, null, null); conv._GameId = ManageGameID(); CreateGame result = Message.Decode <CreateGame>(bytes); Player player = result.PlayerId; player.SetIP(refEp); //add this game to the lobby list of games GamesOnLobby.HandleCreateGame(player, result.MinPlayers, result.MaxPlayers, result.GameName, conv._GameId); conv.Start(); }