FM WebSocket 4.0

Description
Minimal setup guide for Internet Live Stream via FMWebsocketManager.


Basic Setup

FM WebSocket 4.0 supports “Room System” with customised room name.
All the data are streaming through the self-host node.js server. (server script included in the package)

Thus, there are two parts in this tutorial setup.
Part A: node.js server
Part B: Unity3D FMWebSocketManager

Part A: Node.js server

Our example server is located in our plugin root folder
/FMWebSocket/TestServer_v4.x.x/Resources/FMWebSocket

1. Install npm + node.js
Download and install necessary items https://nodejs.org/en/download/

2. Install express
https://expressjs.com/en/starter/installing.html
cmd/terminal: npm init
cmd/terminal: Enter…
cmd/terminal: npm install express –save

3. Install ws module
cmd/terminal: npm install ws

4. Finish & Test on localhost

You may follow this step-by-step tutorial, the commands are compatible in Mac/Windows/Linux
https://youtu.be/Zjm5KGHyceU

Part B: Unity3D FM WebSocket Manager Setup

1. Create a new GameObject in your scene, and name it “FM WebSocket Manager”.
2. Add Component FMWebSocketManager.cs
3. Choose Network Type: Room
4. enabled Auto Init is recommended, which will automatically start the connection in runtime.
5. you may also connect them manually as alternative via script.

//All node.js server examples are included in "/FMWebSocket/TestServer_v4.x.x"

//---------------- For NetworkType: Room ----------------
//Connect as "Room" network type, Create or Join Room with customised name
FMWebSocketManager.instance.Action_JoinOrCreateRoom("MyRoomTest");
//Close connection from node.js Server
FMWebSocketManager.instance.Action_Close();
//Request for Network identify "RoomMaster"
FMWebSocketManager.instance.Action_RequestRoomMaster();

//Send to all Room Clients including yourself
FMWebSocketManager.instance.SendToAll(byte[] _byteData);
FMWebSocketManager.instance.SendToAll(string _stringData);
//Send to Room Master
FMWebSocketManager.instance.SendToServer(byte[] _byteData);
FMWebSocketManager.instance.SendToServer(string _stringData);
//Send to Others
FMWebSocketManager.instance.SendToOthers(byte[] _byteData);
FMWebSocketManager.instance.SendToOthers(string _stringData);
//Send to Target WISD in the same room
FMWebSocketManager.instance.SendToTarget(byte[] _byteData, string _wsid);
FMWebSocketManager.instance.SendToTarget(string _stringData, string _wsid);
//---------------- For NetworkType: Room ----------------

//---------------- For NetworkType: WebSocket only ----------------
//Connect as "WebSocket" network type, WebSocket Mode is only for standard websocket connection
FMWebSocketManager.instance.Action_InitAsWebSocket();
FMWebSocketManager.instance.WebSocketSend(byte[] _byteData);
FMWebSocketManager.instance.WebSocketSend(string _stringData);
//---------------- For NetworkType: WebSocket only ----------------