Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
hi it will be fine to add part about integration with other languages. Iv made issue abut that. hikalkan#32
  • Loading branch information
michaelmnich authored May 29, 2018
1 parent fd048db commit 411024f
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,39 @@ SCS - TCP Server/Client Communication and RMI Framework
You can download SCS binaries and source codes directly from here (Github).

If you're using Visual Studio, you can get from Nuget (https://www.nuget.org/packages/SCS).

Integration with other languages:
JAVA:

Creatinng text msg fur scsTextMessage:
private static void WriteInt32(byte[] buffer, int startIndex, int number)
{
buffer[startIndex] = (byte)((number >> 24) & 0xFF);
buffer[startIndex + 1] = (byte)((number >> 16) & 0xFF);
buffer[startIndex + 2] = (byte)((number >> 8) & 0xFF);
buffer[startIndex + 3] = (byte)((number) & 0xFF);
}


public static byte[] GetBytes(String message) throws UnsupportedEncodingException {

byte[] serializedMessage = message.getBytes("UTF-8");


int messageLength = serializedMessage.length;


//Create a byte array including the length of the message (4 bytes) and serialized message content
byte[] bytes = new byte[messageLength + 4];
WriteInt32(bytes, 0, messageLength);
System.arraycopy(serializedMessage, 0, bytes, 4, messageLength);


return bytes;
}

Usage:
String str = "some text\n";
byte[] b = GetBytes(str);
DataOutputStream outToServer = new DataOutputStream(clientSocket.getOutputStream());
outToServer.write(b, 0, b.length);

0 comments on commit 411024f

Please sign in to comment.