mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 14:28:43 +00:00
WIP: Implemented a temporary workaround to send an instance test to client server upon connection.
Still needs reengineering to change socket channels for sending to ouput stream in the message class. Only client to server "working". #story[1047] #pair[hyi25, wmu16] #pair[cir27, zyt10]
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package seng302.server.messages;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.SocketChannel;
|
||||
|
||||
/**
|
||||
@@ -27,7 +28,7 @@ public class BoatActionMessage extends Message{
|
||||
* @param outputStream The output stream to send the message
|
||||
*/
|
||||
public void send(SocketChannel outputStream) throws IOException {
|
||||
System.out.println("Sending boat action type: " + actionType.toString());
|
||||
System.out.println("[CLIENT] Sending boat action type: " + actionType.toString());
|
||||
allocateBuffer();
|
||||
writeHeaderToBuffer();
|
||||
// Write message fields
|
||||
@@ -37,4 +38,15 @@ public class BoatActionMessage extends Message{
|
||||
|
||||
outputStream.write(getBuffer());
|
||||
}
|
||||
|
||||
|
||||
public ByteBuffer stealBuffer() {
|
||||
allocateBuffer();
|
||||
writeHeaderToBuffer();
|
||||
// Write message fields
|
||||
putInt((int) BoatActionType.getBoatPacketType(actionType), 1);
|
||||
writeCRC();
|
||||
rewind();
|
||||
return getBuffer();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user