Created
March 20, 2017 21:23
-
-
Save rustinlee/ed6c2fb87389e906fc12644e35559dbe to your computer and use it in GitHub Desktop.
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 System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
using System; | |
using System.Net.Sockets; | |
using System.IO; | |
using System.IO.Pipes; | |
using System.Text; | |
public class IPCTester : MonoBehaviour { | |
NamedPipeClientStream clientStream; | |
StreamWriter writer; | |
StreamReader reader; | |
void Start() { | |
clientStream = new NamedPipeClientStream("tmp-app.normal"); | |
clientStream.Connect(); | |
writer = new StreamWriter(clientStream); | |
reader = new StreamReader(clientStream); | |
} | |
void Update() { | |
} | |
void Ping() { | |
string pingString = "{ \"type\": \"pong\", \"data\": { \"status\": \"ok\" }\r\n"; | |
byte[] buffer = Encoding.UTF8.GetBytes(pingString); | |
clientStream.WaitForPipeDrain(); | |
writer.Write(pingString); | |
writer.Flush(); | |
} | |
private void OnGUI() { | |
if (GUI.Button(new Rect(10, 10, 150, 100), "Ping")) | |
Ping(); | |
} | |
private void OnApplicationQuit() { | |
clientStream.Dispose(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment