Class EngineIOClient
- Namespace
- Firesplash.GameDevAssets.SocketIOPlus.EngineIO
- Assembly
- Firesplash.GameDevAssets.SocketIOPlus.dll
This component allows creating or accessing a "low level" EngineIO connection. It is created as a subset of our Socket.IO implementation but if required, you can directly access it for example to create your own protocol on top of Engine.IO It does not implement 100% of Engine.IO API but is enough for All-Day usage. The implementation of BINARY Engine.IO messages is untested and provided without warranty. Feel free to report bugs to us though.
[DisallowMultipleComponent]
[AddComponentMenu("Networking/Socket.IO/Low-Level Engine.IO Client")]
public class EngineIOClient : MonoBehaviour
- Inheritance
-
EngineIOClient
- Derived
Fields
OnEngineIOConnectionReady
[HideInInspector]
public UnityEvent<DataTypes.ConnectionParameters> OnEngineIOConnectionReady
Field Value
- UnityEvent<DataTypes.ConnectionParameters>
OnEngineIOConnectionReadyThreaded
This native C# callback is invoked immediately when an Engine.IO connection has been established and the handshake is done. Warning: If using Threaded and dispatched events, UnityEvents may be invoked out of order compared to only one kind of events. (You might receive Threaded Event 1, 2, 3 before actually receiving UnityEvent 2 for example) This callback is invoked from a thread!
public DataTypes.EngineIOConnectionReadyEvent OnEngineIOConnectionReadyThreaded
Field Value
OnEngineIODisconnect
[HideInInspector]
public UnityEvent<bool, string> OnEngineIODisconnect
Field Value
OnEngineIOError
[HideInInspector]
public UnityEvent<Exception> OnEngineIOError
Field Value
- UnityEvent<Exception>
OnEngineIOMessageReceived
This UnityEvent is fired on the main thread after an Engine.IO message packet has been received on the websocket. Due to dispatching, it can be slightly delayed.
[HideInInspector]
public UnityEvent<EngineIOPacket> OnEngineIOMessageReceived
Field Value
- UnityEvent<EngineIOPacket>
OnEngineIOMessageReceivedThreaded
This native C# callback is invoked immediately when an Engine.IO message packet is received on the websocket. Warning: If using Threaded and dispatched events, UnityEvents may be invoked out of order compared to only one kind of events. (You might receive Threaded Event 1, 2, 3 before actually receiving UnityEvent 2 for example) This callback is invoked from a thread!
public DataTypes.EngineIOMessageReceivedEvent OnEngineIOMessageReceivedThreaded
Field Value
serverAddress
public string serverAddress
Field Value
volatileOperationMode
[Tooltip("If enabled, the library will drop all packets from the send queue that could not be transmitted when they were scheduled to be sent. Additionally the send queue is cleared on (re)connect.\nThis is very similar to the 'Volatile' Socket.IO mode and feels a bit like UDP - probably the best for realtime data.\n\nWhen disabled, queues are kept across reconnects and failed transmisions will be re-queued until they succeed, which is similar to the default Socket.IO mode. This has high reliability but can cause jams.")]
public bool volatileOperationMode
Field Value
Properties
SendQueueLength
Returns the length of the current data send queue in transmissions/emits Warning: This is a blocking and quite slow call.
public int SendQueueLength { get; }
Property Value
State
Returns the connection state of the Engine.IO connection
public DataTypes.ConnectionState State { get; }
Property Value
Methods
Awake()
public void Awake()
ClearSendQueue()
This clears the data send queue
public void ClearSendQueue()
Connect(string)
Connect the client to the server
public virtual void Connect(string pServerAddress = null)
Parameters
pServerAddress
string
Connect(string, bool)
Connect the client to the server
public virtual void Connect(string pServerAddress, bool volatileMode)
Parameters
pServerAddress
stringvolatileMode
boolIf true, failed transmissions are not retried and queue is cleared on connect. A little like UDP. - If false, failed transmissions are re-queued.
Disconnect()
Disconnect the Engine.IO client
public virtual void Disconnect()
LateUpdate()
protected void LateUpdate()
SendEngineIOMessage(byte[])
Sends a binary message to the server using raw Engine.IO protocol
public void SendEngineIOMessage(byte[] message)
Parameters
message
byte[]The message
SendEngineIOMessage(string)
Sends a string message to the server using raw Engine.IO protocol
public void SendEngineIOMessage(string message)
Parameters
message
stringThe message
SendEngineIOPacket(EngineIOPacket)
Sends a previously built Engine.IO packet without modification
public void SendEngineIOPacket(EngineIOPacket packet)
Parameters
packet
EngineIOPacketThe packet
SendEngineIOPackets(EngineIOPacket[])
Sends multiple previously built Engine.IO packets without modification in row
public void SendEngineIOPackets(EngineIOPacket[] packets)
Parameters
packets
EngineIOPacket[]The packet array