ConnectHub
Namespace: SynicSugar.P2P
Description
Manage around p2p connections.
This script is Singleton generated by SourceGenerator. This behaves like a network server, and SynicSugar send and receive packets through this ConnectHub.
At compile, SourceGenerator generates a ConnectHub for each assembly with variables and functions according for the Network attribute. In other words, each assembly has different ConnectHub and that instance. Usually an instance calls ConnectHub in the same assembly automatically. There is no need for us to do anything special for this.
Each assembly can have max 250 variables and functions with Network attribute (share the limit with SyncVar, RPC and TargetRPC).
Properity
API | description |
---|---|
Instance | This scrip's instance |
Channels | List of all variable and functions having Network attribute |
Function
API | description |
---|---|
StartSynicReceiver | Start the synic receiver to get only synic packet from buffer |
StartPacketReceiver | (Re)Start the packet receiver to get packet from buffer |
StopPacketReceiver | Stop to get a packet from the buffer |
PauseConnections | Pause receiving a packet to the receive buffer |
RestartConnections | Restart to receive packets receive buffer |
ExitSession | Leave connection |
CloseSession | Close connection. (If Host, close the Lobby) |
DestoryOfflineLobby | Destory offline-lobby and stop offline mode |
RegisterInstance | Register instance to receive packets |
GetUserInstance | Get a NetworkPlayer instance of target user registered to ConnectHub |
GetInstance | Get a NetworkCommons instance registered to ConenctHub |
SyncSynic | Synchronize all own Synic variables at once to TargetUser |
ResendLastRPC | Re-Send RPC with last recorded information |
ResendLastRPCToTarget | Re-Send RPC to the specific target with last recorded information |
ResendLastTargetRPC | Re-Send TargetRPC with last recorded information. |
using SynicSugar.P2P;
public class p2pSample {
public void StartConnection(){
ConnectHub.Instance.StartPacketReceiver();
}
}