internal virtual void SendPackage(byte[] data) { lock (NetworkSession.OutputStream) { CytarStreamWriter cw = new CytarStreamWriter(NetworkSession.OutputStream); cw.Write(data.Length); cw.Write(data, 0, data.Length); NetworkSession.OutputStream.Flush(); } }
internal virtual void SendPackage(MemoryStream sourceStream) { lock (NetworkSession.OutputStream) { CytarStreamReader cr = new CytarStreamReader(sourceStream); CytarStreamWriter cw = new CytarStreamWriter(NetworkSession.OutputStream); cw.Write((int)sourceStream.Length); cw.Write(cr.ReadBytes((int)sourceStream.Length)); //sourceStream.CopyTo(NetworkSession.OutputStream); } }
protected virtual RemoteAPIInfo CallRemoteAPIAndGetInfo(string apiName, Type returnType, Action <object> returnCallback, Action <RemoteException> errorCallback, params object[] param) { var callingID = NextCallingID; RemoteAPIInfo remoteAPI = new RemoteAPIInfo(apiName, callingID, returnType, returnCallback, errorCallback); RemoteCallingRecode.Add(remoteAPI.CallingID, remoteAPI); MemoryStream ms = new MemoryStream(); CytarStreamWriter cw = new CytarStreamWriter(ms); cw.Write(callingID); cw.Write(apiName); foreach (var arg in param) { cw.Write(arg); } ms.Position = 0; SendPackage(ms); return(remoteAPI); }