RFC
- Packet
opcode=7
: SERV gives CLIENT1 information about CLIENT2
+--------+------+---------+---------+
| opcode | port | IP size | address |
+--------+------+---------+---------+
| 7 | int | int | bytes |
+--------+------+---------+---------+
- We don't need to know if the client exists or not (client's responsability).
- An IP Address is encoded as a sequence of bytes. It will always be preceded by the size of the address, coded in an int.
IPv4 = 32 bits = 4 bytes
IPv6 = 128 bits = 16 bytes
Client.java
processInput()
:- Now parses commands (
args
style), to make theswitch
code easier for commands with arguments. - Is now safer to use for developpers : all cases end with
break
, forget about thereturn
thing.
- Now parses commands (
- Renamed
/w
command to/private
. Because/w
will be used later for private messages.- Syntax :
/private nickname
requests a private communication tonickname
. - Client is now able to write packets
opcode=6
to the server. - Client is now able to read packets
opcode=7
from the server.
- Syntax :
- Added method
packetClientInfoRequest()
. - Added method
receiveClientInfoReply()
. Added methodreadAddress()
. - Progress :
OPCODE NAMING STATUS
6 packetClientInfoRequest() done
7 receiveClientInfoReply() working sysout tests
8 packetPrivateComRequest() todo
9 receivePrivateComReply() todo
Context.java
- Added packet
opcode=6
to the supported received packets. (+ CommandReader.java) - Added method
receivedClientInfoRequest()
: server retrieves the destination nickname, gets the destination'sContext
, then gets the port and IP from thatContext
, and build the reply to the client.
Server.java
- Added method
getContextByNickname()
.
ClientGUI.java
- New class for a simple graphical user interface.
- ClientGUI will now retrieve user inputs, and give them to Client with this method. As ClientGUI is event based, the
while (!hasQuit && scanner.hasNextLine())
is no longer needed.
Client.java
- Added
ClientGUI
as a private field. - Anytime you want to use
System.out.println()
for the chat, now useClientGUI.println()
instead. Easy. getInput()
method was removed.processInput()
was added. It is called by ClientGUI when an user input event was triggered.- leaved -> left
Client.java
- Charsets, which are defined in the RFC, have been encapsulated.
- Casts in readByte conditions were removed, == supports bytes.
- Added enum OpCode and a readOpCode method to decrease confusion given the huge number of incoming different readBytes calls.
- Added a logger.
- Code fully documented.
Context.java
- refuseConnection now takes an error code as a parameter (cf RFC).
- Now refuses connection to clients with nicknames that are too long.