Interface INetworkDriver
The NetworkDriver interface is the main entry point for the transport.
The Driver is similar to a UDP socket which can handle many connections.
Syntax
public interface INetworkDriver : IDisposable
Properties
IsCreated
Declaration
Property Value
Listening
Declaration
Property Value
Methods
Accept()
Accept a pending connection attempt and get the established connection.
This should be called until it returns an invalid connection to make sure
all connections are accepted.
Declaration
NetworkConnection Accept()
Returns
Type |
Description |
NetworkConnection |
Returns a newly created NetworkConnection if it was Successful and a default(NetworkConnection)
if there where no more new NetworkConnections to accept.
|
Bind(NetworkEndPoint)
Bind the NetworkDriver to a port locally. This must be called before
the socket can listen for incoming connections.
Declaration
int Bind(NetworkEndPoint endpoint)
Parameters
Returns
Type |
Description |
Int32 |
Returns 0 on Success.
|
Connect(NetworkEndPoint)
Establish a new connection to a server with a specific address and port.
Declaration
NetworkConnection Connect(NetworkEndPoint endpoint)
Parameters
Type |
Name |
Description |
NetworkEndPoint |
endpoint |
A valid NetworkEndPoint, can be implicitly cast using an System.Net.IPEndPoint
|
Returns
CreatePipeline(Type[])
Create a pipeline which can be used to process data packets sent and received by the transport package.
The pipelines must be created in the same order on the client and server since they are identified by
an index which is assigned on creation.
All pipelines must be created before the first connection is established.
Declaration
NetworkPipeline CreatePipeline(params Type[] stages)
Parameters
Type |
Name |
Description |
Type[] |
stages |
|
Returns
Disconnect(NetworkConnection)
Disconnect an existing connection.
Declaration
int Disconnect(NetworkConnection con)
Parameters
Returns
Type |
Description |
Int32 |
Returns 0 on Success.
|
GetConnectionState(NetworkConnection)
Get the state of an existing connection. If called with an invalid connection the call will return the Destroyed state.
Declaration
NetworkConnection.State GetConnectionState(NetworkConnection con)
Parameters
Returns
Listen()
Enable listening for incoming connections on this driver. Before calling this
all connection attempts will be rejected.
Declaration
Returns
Type |
Description |
Int32 |
Returns 0 on Success.
|
LocalEndPoint()
Declaration
NetworkEndPoint LocalEndPoint()
Returns
PopEvent(out NetworkConnection, out DataStreamReader)
Receive an event for any connection.
Declaration
NetworkEvent.Type PopEvent(out NetworkConnection con, out DataStreamReader bs)
Parameters
Returns
PopEventForConnection(NetworkConnection, out DataStreamReader)
Receive an event for a specific connection. Should be called until it returns Empty, even if the socket is disconnected.
Declaration
NetworkEvent.Type PopEventForConnection(NetworkConnection con, out DataStreamReader bs)
Parameters
Returns
RemoteEndPoint(NetworkConnection)
Declaration
NetworkEndPoint RemoteEndPoint(NetworkConnection con)
Parameters
Returns
ScheduleUpdate(JobHandle)
Schedule a job to update the state of the NetworkDriver, read messages and events from the underlying
network interface and populate the event queues to allow reading from connections concurrently.
Declaration
JobHandle ScheduleUpdate(JobHandle dep = null)
Parameters
Type |
Name |
Description |
JobHandle |
dep |
Used to chain dependencies for jobs.
|
Returns
Type |
Description |
JobHandle |
A for the ScheduleUpdate Job.
|
Send(NetworkPipeline, NetworkConnection, IntPtr, Int32)
Send a message to the specific connection.
Declaration
int Send(NetworkPipeline pipe, NetworkConnection con, IntPtr data, int len)
Parameters
Returns
Send(NetworkPipeline, NetworkConnection, DataStreamWriter)
Send a message to the specific connection.
Declaration
int Send(NetworkPipeline pipe, NetworkConnection con, DataStreamWriter strm)
Parameters
Returns
Type |
Description |
Int32 |
Returns the size in bytes that was sent, -1 on failure.
|