-
-
Save kou-yeung/717815f8db946051bed097788a5b7894 to your computer and use it in GitHub Desktop.
Milkcocoa for UnityWebGL Sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using Milkcocoa; | |
class Message | |
{ | |
public string value; | |
} | |
class Foo | |
{ | |
MilkCocoa milkcocoa = new MilkCocoa("Your API Key"); | |
DataStore dataStore; | |
void Start() | |
{ | |
dataStore = milkcocoa.DataStore("chat"); | |
dataStore.OnSend((json) => { | |
var message = JsonUtility.FromJson<Message>(json); | |
Debug.Log(message.value); // "Hello!!" will be display. | |
}); | |
dataStore.Send(JsonUtility.ToJson(new Message{value = "Hello!!"})); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment