I try to run c# in unity but I got errors:
- error CS0234: The type or namespace name
Pipes' does not exist in the namespace
System.IO’. Are you missing an assembly reference? - error CS0234: The type or namespace name
Unix' does not exist in the namespace
Mono’. Are you missing an assembly reference?
How I can to convert the code to something that run on Unity?
code:
using System;
using System.IO;
using System.IO.Pipes;
using System.Net;
using System.Net.Sockets;
using System.Xml;
#if __MonoCS__
using Mono.Unix;
#endif
namespace Mumble {
public class Mumble {
protected NamedPipeClientStream pipe;
protected StreamReader sr;
protected StreamWriter sw;
public Mumble() {
#if __MonoCS__
Socket s = new Socket(AddressFamily.Unix, SocketType.Stream, 0);
UnixEndPoint ue = new UnixEndPoint(Environment.GetFolderPath(System.Environment.SpecialFolder.Personal) + "/.MumbleSocket");
s.Connect(ue);
NetworkStream pipe = new NetworkStream(s);
#else
pipe = new NamedPipeClientStream("Mumble");
pipe.Connect();
#endif
sr = new StreamReader(pipe);
sw = new StreamWriter(pipe);
}
private bool OutputStringReply() {
String line;
while ((line = sr.ReadLine()) != "") {
Console.WriteLine(line);
}
return true;
}
private bool ReadReply() {
bool reply;
using (XmlReader xr = XmlReader.Create(sr)) {
xr.MoveToContent();
xr.ReadToDescendant("succeeded");
reply = xr.ReadElementContentAsBoolean();
}
return reply;
}
public bool Mute(bool state) {
sw.WriteLine("<self mute='{0}' />", state);
sw.Flush();
return ReadReply();
}
public bool Deaf(bool state) {
sw.WriteLine("<self deaf='{0}' />", state);
sw.Flush();
return ReadReply();
}
public bool Focus() {
sw.WriteLine("<focus />");
sw.Flush();
return ReadReply();
}
public bool OpenUrl(String url) {
Uri u;
Uri.TryCreate(url, UriKind.Absolute, out u);
sw.WriteLine("<url><href>{0}</href></url>", u);
sw.Flush();
return ReadReply();
}
public String QueryUrl() {
sw.WriteLine("<url />");
sw.Flush();
String reply;
using (XmlReader xr = XmlReader.Create(sr)) {
xr.MoveToContent();
xr.ReadToDescendant("href");
reply = xr.ReadString();
}
return reply;
}
/*
public static void Main(String[] args) {
Mumble m = new Mumble();
m.Deaf(true);
}
*/
}
}