forked from CreativeTechnology/socket.io-unity-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExampleSocketIO.cs
More file actions
35 lines (29 loc) · 833 Bytes
/
ExampleSocketIO.cs
File metadata and controls
35 lines (29 loc) · 833 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System;
//using LitJson; /* For json use litjson.sourceforge.net */
// Inherit from SocketIoClient Class
public class ExampleSocketIO : SocketIoClient {
public string host = "localhost";
public int port = 5000;
void Awake() {
// For Webplayer sandbox:
Security.PrefetchSocketPolicy(host, port);
// Setup Socket Connection
SetupClient("ws://"+host+":"+port+"/socket.io/websocket");
}
void Start() {
// Connect client and start up read thread
StartClient();
}
public void Update() {
// Calls "HandleMessage" if a message was in queue
ProcessQueue();
}
// overrides default "onMessage" behaviour:
public override void HandleMessage(string msg) {
print(msg);
//JsonData message = JsonMapper.ToObject(msg);
}
}