Created
February 21, 2014 14:31
-
-
Save yakreved/9135282 to your computer and use it in GitHub Desktop.
SocketBrowserConnection
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 System.Collections; | |
//передача сообщений между браузером и сокет сервером через Юнити | |
using System.Collections.Generic; | |
using System; | |
public class SocketBrowserConnection : MonoBehaviour | |
{ | |
public static SocketBrowserConnection inst; | |
void Awake() | |
{ | |
inst = this; | |
} | |
public void Start() | |
{ | |
Dbg.Log("init_browser_messages"); | |
//Application.ExternalCall("init_browser_messages"); | |
} | |
//вызывается из браузера | |
void subscribe(string channel) | |
{ | |
Dbg.Log("Browser subscribed at "+ channel); | |
//RouteDict[channel]= SendToBrowser; | |
SocketMessagesDispatcher.main.addRoute(channel,SendToBrowser); | |
} | |
//вызывается из браузера | |
void sendString(string message) | |
{ | |
Dbg.Log("Sending string from browser: "+ message); | |
SocketSender.main.SendData(message); | |
} | |
void SendToBrowser (object message) | |
{ | |
var mess = (SocketMessage)message; | |
Application.ExternalCall( "SocketUnityConnection_receive_string", mess.ToString()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment