Skip to content

C# class that allows communication (send + receive bytes) with a TCP server.

Notifications You must be signed in to change notification settings

mchrbn/TcpCommunication-Unity

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 

Repository files navigation

TcpCommunication - Unity

A simple way to communicate between a Unity client and a server via TCP.

Use

  1. Create an empty GameObject and add the TcpCommunication script on it.
  2. Set your server IP and port.
  3. You can send bytes to your server by using :
bool hasSent = TcpCommunication.Instance.SendBytes(yourBytesArray);
  1. When the server sent you messages, you have to use a delegate in the class/object you need to receive that message:
void OnEnable(){
    TcpCommunication.Instance.OnReceivedMessage += OnReceivedMessage;
}

void OnDisable(){
    TcpCommunication.Instance.OnReceivedMessage -= OnReceivedMessage;
}

void OnReceivedMessage(string str){
    //Do something with your string.
}

About

C# class that allows communication (send + receive bytes) with a TCP server.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages