interface INetworking (Niantic.Experimental.ARDK.SharedAR.INetworking)
Overview
interface INetworking: IDisposable { // properties ConnectionState ConnectionState; bool IsServer; NetworkingStats NetworkingStats; List<IPeerID> PeerIDs; RoomParams RoomParams; IPeerID SelfPeerID; IPeerID ServerPeerId; // events event ConnectionEvent(); event DataReceived(); event PeerAdded(); event PeerRemoved(); // methods void JoinAsPeer(byte[] roomId); void JoinAsServer(byte[] roomId); NetworkingRequestResult KickOutPeer(IPeerID peerID); void Leave(); void SendData( List<IPeerID> dest, uint tag, byte[] data, ConnectionType connectionType ); void SendData< T >( List<IPeerID> dest, uint tag, T data, ConnectionType connectionType = ConnectionType.UseDefault ); void SetDefaultConnectionType(ConnectionType connectionType); };
Detailed Documentation
注釈
This is an experimental feature. Experimental features should not be used in production products as they are subject to breaking changes, not officially supported, and may be deprecated without notice
Properties
ConnectionState ConnectionState
Get the latest connection state
Returns:
bool IsServer
Returns if self is a “server”
Returns:
true if this networking is server role, false if this networking is client role
注釈
This is currently unimplemented
NetworkingStats NetworkingStats
Get networking stats RTT, bps, packet loss, etc…
Returns:
current network stats struct
注釈
This is currently unimplemented
List<IPeerID> PeerIDs
Get all PeerIDs actively connected to the room
Returns:
List of all Peer IDs actively connected to the room
RoomParams RoomParams
Get room config of the currrently connected room RoomConfig include name, ID, geo info, etc.
Returns:
the room current of the currrently connected room
注釈
This is currently unimplemented - joining happens on INetworking creation
IPeerID SelfPeerID
Return the self Peer ID
Returns:
self Peer ID
IPeerID ServerPeerId
Return the server peer ID
Returns:
server Peer ID. Invalid peer ID if no server role in the current room
注釈
This is currently unimplemented
Events
event PeerRemoved()
Event fired when a peer is removed, either from intentional action, timeout, or error.
Methods
void JoinAsPeer(byte[] roomId)
Join the networking as a peer.
注釈
This is currently unimplemented - joining happens on INetworking creation
void JoinAsServer(byte[] roomId)
Join the networking as a server.
注釈
This is currently unimplemented - joining happens on INetworking creation
NetworkingRequestResult KickOutPeer(IPeerID peerID)
Disconnect the specified peer Can do only by server. TODO: Should be async?
Parameters:
peerID |
PeerID of the peer to be kicked out |
Returns:
result of the request
注釈
This is currently unimplemented
void Leave()
Disconnect from network and datastore.
void SendData( List<IPeerID> dest, uint tag, byte[] data, ConnectionType connectionType )
Send data to the specified peers. Receiving peers will have a DataReceived event fired
Parameters:
dest |
Destination of the message. destination could be peer ID, “server” peer ID, list of peer IDs, or empty for broadcast |
tag |
Data tag that peers will receive |
data |
Byte[] to send |
connectionType |
Protocol to send the data with |
void SendData< T >( List<IPeerID> dest, uint tag, T data, ConnectionType connectionType = ConnectionType.UseDefault )
Send an object to the specified peers. Receiving peers will have a DataReceived event fired.
Parameters:
dest |
Destination of the message. destination could be peer ID, “server” peer ID, list of peer IDs, or empty for broadcast |
tag |
Data tag that peers will receive |
data |
Object to send |
connectionType |
Protocol to send the data with |
注釈
This is currently unimplemented
void SetDefaultConnectionType(ConnectionType connectionType)
Set the default protocol for networked messages on this session
Parameters:
connectionType |
Protocol to send the data with |
注釈
This is currently unimplemented