Merge remote-tracking branch 'origin/text_chat' into text_chat

This commit is contained in:
Calum
2017-09-04 23:11:02 +12:00
5 changed files with 69 additions and 1 deletions
@@ -303,7 +303,7 @@ public class ClientToServerThread implements Runnable {
}
}
private void closeSocket() {
public void closeSocket() {
try {
socket.close();
socketOpen = false;
@@ -234,6 +234,7 @@ public class GameClient {
private void parsePackets() {
while (socketThread.getPacketQueue().peek() != null) {
System.out.println("PARSING PACKET");
StreamPacket packet = socketThread.getPacketQueue().poll();
switch (packet.getType()) {
case RACE_STATUS:
@@ -297,6 +298,8 @@ public class GameClient {
case CHATTER_TEXT:
Pair<Integer, String> playerIdMessagePair = StreamParser
.extractChatterText(packet);
System.out.println("playerIdMessagePair = " + playerIdMessagePair);
raceView.updateChatHistory(
allBoatsMap.get(playerIdMessagePair.getKey()).getColour(),
playerIdMessagePair.getValue()
@@ -457,4 +460,9 @@ public class GameClient {
}
}
public ClientToServerThread getSocketThread() {
return socketThread;
}
}
+5
View File
@@ -0,0 +1,5 @@
Feature: SendChat
Scenario: User send chat to another client
Given The are two games running
When the user has pressed sends the message "Hello world" in a text box
Then the other client should recieve the message "Hello world"
+53
View File
@@ -0,0 +1,53 @@
package steps;
import cucumber.api.PendingException;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;
import java.util.ArrayList;
import javafx.scene.layout.Pane;
import org.junit.Assert;
import org.mockito.Mock;
import seng302.gameServer.GameStages;
import seng302.gameServer.GameState;
import seng302.gameServer.MainServerThread;
import seng302.gameServer.messages.BoatAction;
import seng302.model.ServerYacht;
import seng302.visualiser.ClientToServerThread;
import seng302.visualiser.GameClient;
import seng302.visualiser.controllers.StartScreenController;
/**
* Created by kre39 on 7/08/17.
*/
public class SendChatSteps {
MainServerThread mst;
GameClient client1;
GameClient client2;
//TODO Need to mock the controller pane in order to run the full game client
@Given("^The are two games running$")
public void the_are_two_games_running() throws Throwable {
// client1 = new GameClient(new Pane());
// client1.runAsHost("localhost", 4942);
//// client2 = new ClientToServerThread("localhost", 4942);
// GameState.setCurrentStage(GameStages.RACING);
// Thread.sleep(200);
}
@When("^the user has pressed sends the message \"([^\"]*)\" in a text box$")
public void the_user_has_pressed_sends_the_message_in_a_text_box(String arg1) throws Throwable {
// client1.getSocketThread().sendChatterMessage(arg1);
}
@Then("^the other client should recieve the message \"([^\"]*)\"$")
public void the_other_client_should_recieve_the_message(String arg1) throws Throwable {
// System.out.println(client2.getPacketQueue());
// client2.setSocketToClose();
}
}
+2
View File
@@ -49,5 +49,7 @@ public class ToggleSailSteps {
} else {
Assert.assertFalse(yacht.getSailIn());
}
mst.terminate();
client.closeSocket();
}
}