NDream.AirConsole.WebsocketListener.ProcessMessage C# (CSharp) Method

ProcessMessage() public method

public ProcessMessage ( string data ) : void
data string
return void
		public void ProcessMessage (string data) {

			try {

				// parse json string
				JObject msg = JObject.Parse (data);

				if ((string)msg ["action"] == "onReady") {

					this.isReady = true;

					if (this.onReady != null) {
						this.onReady (msg);
					}

					if (Settings.debug.info) {
						Debug.Log ("AirConsole: Connections are ready!");
					}
				} else if ((string)msg ["action"] == "onMessage") {

					if (this.onMessage != null) {
						this.onMessage (msg);
					}
				} else if ((string)msg ["action"] == "onDeviceStateChange") {

					if (this.onDeviceStateChange != null) {
						this.onDeviceStateChange (msg);
					}
				} else if ((string)msg ["action"] == "onConnect") {
					
					if (this.onConnect != null) {
						this.onConnect (msg);
					}
				} else if ((string)msg ["action"] == "onDisconnect") {
					
					if (this.onDisconnect != null) {
						this.onDisconnect (msg);
					}
				} else if ((string)msg ["action"] == "onCustomDeviceStateChange") {

					if (this.onCustomDeviceStateChange != null) {
						this.onCustomDeviceStateChange (msg);
					}
				} else if ((string)msg ["action"] == "onDeviceProfileChange") {
					
					if (this.onDeviceProfileChange != null) {
						this.onDeviceProfileChange (msg);
					}
				} else if ((string)msg ["action"] == "onAdShow") {
					
					if (this.onAdShow != null) {
						this.onAdShow (msg);
					}
				} else if ((string)msg ["action"] == "onAdComplete") {
					
					if (this.onAdComplete != null) {
						this.onAdComplete (msg);
					}
				} else if ((string)msg ["action"] == "onGameEnd") {
					
					if (this.onGameEnd != null) {
						this.onGameEnd (msg);
					}
				} else if ((string)msg ["action"] == "onHighScores") {
					
					if (this.onHighScores != null) {
						this.onHighScores (msg);
					}
				} else if ((string)msg ["action"] == "onHighScoreStored") {
					
					if (this.onHighScoreStored != null) {
						this.onHighScoreStored (msg);
					}
				} else if ((string)msg ["action"] == "onPersistentDataStored") {
					
					if (this.onPersistentDataStored != null) {
						this.onPersistentDataStored (msg);
					}
				} else if ((string)msg ["action"] == "onPersistentDataLoaded") {
					
					if (this.onPersistentDataLoaded != null) {
						this.onPersistentDataLoaded (msg);
					}
				} else if ((string)msg ["action"] == "onPremium") {
					
					if (this.onPremium != null) {
						this.onPremium (msg);
					}
				} else if ((string)msg ["action"] == "onLaunchApp") {

					if (this.onLaunchApp != null) {
						this.onLaunchApp (msg);
					}
				} else if ((string)msg ["action"] == "onUnityWebviewResize") {

					if (this.onUnityWebviewResize != null) {
						this.onUnityWebviewResize (msg);
					}
				} else if ((string)msg ["action"] == "onUnityWebviewPlatformReady") {
					
					if (this.onUnityWebviewPlatformReady != null) {
						this.onUnityWebviewPlatformReady (msg);
					}
				}


			} catch (Exception e) {

				if (Settings.debug.error) {
					Debug.LogError (e.Message);
					Debug.LogError (e.StackTrace);
				}
			}
		}

Usage Example

 public void ProcessJS(string data)
 {
     wsListener.ProcessMessage(data);
 }