public InboundPacket(NetworkStream stream) { for (int i = 0; i < 8; i++) stream.ReadByte(); byte[] dataSizeRaw = new byte[4]; for (int i = 0; i < 4; i++) dataSizeRaw[i] = (byte)stream.ReadByte(); byte[] dataSizeBE = new byte[4]; dataSizeBE[0] = dataSizeRaw[3]; dataSizeBE[1] = dataSizeRaw[2]; dataSizeBE[2] = dataSizeRaw[1]; dataSizeBE[3] = dataSizeRaw[0]; int dataSize = BitConverter.ToInt32(dataSizeBE, 0); for (int i = 0; i < 4; i++) stream.ReadByte(); byte[] dataPacketRaw = new byte[dataSize]; for (int i = 0; i < dataSize; i++) dataPacketRaw[i] = (byte)stream.ReadByte(); byte[] dataPacketTrimmed = new byte[dataPacketRaw.Length - 3]; for (int i = 0; i < dataPacketTrimmed.Length; i++) dataPacketTrimmed[i] = dataPacketRaw[i]; Message = System.Text.Encoding.ASCII.GetString(dataPacketTrimmed).Substring(2); Prefix = Message.Substring(0, 3); }
public void Read(NetworkStream stream) { EntityID = StreamHelper.ReadInt(stream); X = (sbyte)stream.ReadByte(); Y = (sbyte)stream.ReadByte(); Z = (sbyte)stream.ReadByte(); }
public void Read(NetworkStream stream) { WindowId = (byte)stream.ReadByte(); WindowType = (WindowTypes)stream.ReadByte(); Title = StreamHelper.ReadString(stream); Slots = (byte)stream.ReadByte(); }
public static ArrayList Read(NetworkStream stream) { ArrayList list = new ArrayList(); for (byte b = (byte)stream.ReadByte(); b != 127; b = (byte)stream.ReadByte()) { int i = (b & 0xe0) >> 5; int j = b & 0x1f; WatchableObject obj = null; switch (i) { case 0: //Byte obj = new WatchableObject(i, j, (byte)stream.ReadByte()); break; case 1: //Short obj = new WatchableObject(i, j, StreamHelper.ReadShort(stream)); break; case 2: //Int obj = new WatchableObject(i, j, StreamHelper.ReadInt(stream)); break; case 3: //Float obj = new WatchableObject(i, j, StreamHelper.ReadFloat(stream)); break; case 4: //String obj = new WatchableObject(i, j, StreamHelper.ReadString(stream)); break; case 5: //Item stack obj = new WatchableObject(i, j, new ItemStack(StreamHelper.ReadShort(stream), stream.ReadByte(), StreamHelper.ReadShort(stream))); break; } list.Add(obj); } return list; }
public void Read(NetworkStream stream) { a = StreamHelper.ReadInt(stream); b = stream.ReadByte(); c = StreamHelper.ReadInt(stream); d = stream.ReadByte(); e = StreamHelper.ReadInt(stream); }
public void Read(NetworkStream stream) { X = StreamHelper.ReadInt(stream); Y = StreamHelper.ReadShort(stream); Z = StreamHelper.ReadInt(stream); Instrument = (InstrumentType)stream.ReadByte(); Pitch = (byte)stream.ReadByte(); }
public void Read(NetworkStream stream) { X = StreamHelper.ReadInt(stream); Y = stream.ReadByte(); Z = StreamHelper.ReadInt(stream); BlockType = stream.ReadByte(); Metadata = stream.ReadByte(); }
public void Read(NetworkStream stream) { Status = stream.ReadByte(); X = StreamHelper.ReadInt(stream); Y = stream.ReadByte(); Z = StreamHelper.ReadInt(stream); FaceType = (Face)stream.ReadByte(); }
public void Read(NetworkStream stream) { EntityID = StreamHelper.ReadInt(stream); Name = StreamHelper.ReadString(stream); X = StreamHelper.ReadInt(stream); Y = StreamHelper.ReadInt(stream); Z = StreamHelper.ReadInt(stream); Rotation = (byte)stream.ReadByte(); Pitch = (byte)stream.ReadByte(); CurrentItem = StreamHelper.ReadShort(stream); }
public void Read(NetworkStream stream) { EntityID = StreamHelper.ReadInt(stream); MobType = (byte)stream.ReadByte(); X = StreamHelper.ReadInt(stream); Y = StreamHelper.ReadInt(stream); Z = StreamHelper.ReadInt(stream); Yaw = (sbyte)stream.ReadByte(); Pitch = (sbyte)stream.ReadByte(); Metadata = DataWatcher.Read(stream); }
public void Read(NetworkStream stream) { EntityID = StreamHelper.ReadInt(stream); ItemID = StreamHelper.ReadShort(stream); Count = (byte)stream.ReadByte(); Secondary = StreamHelper.ReadShort(stream); X = StreamHelper.ReadInt(stream); Y = StreamHelper.ReadInt(stream); Z = StreamHelper.ReadInt(stream); Rotation = (byte)stream.ReadByte(); Pitch = (byte)stream.ReadByte(); Roll = (byte)stream.ReadByte(); }
public Session(string host, int port, string username, string pw) { socket = new TcpClient(host, port); stream = socket.GetStream(); ehost = host; string[] response = Receive().Split(':'); string nonce; string code; if (response.Length > 1) { code = username + ":" + response[0] + ":" + pw; nonce = response[1]; } else { code = pw; nonce = response[0]; } Send(username); Send(MD5(MD5(code) + nonce)); if (stream.ReadByte() != 0) { throw new IOException("Access denied."); } }
public void Read(NetworkStream stream) { Name = (byte)stream.ReadByte(); Length = StreamHelper.ReadShort(stream); Items = new ItemStack[Length]; for (int i = 0; i < Length; i++) { short primary = StreamHelper.ReadShort(stream); if (primary >= 0) { byte count = (byte)stream.ReadByte(); short secondary = StreamHelper.ReadShort(stream); Items[i] = new ItemStack(primary, count, secondary); } } }
public void Read(NetworkStream stream) { WindowID = (byte)stream.ReadByte(); Slot = StreamHelper.ReadShort(stream); short word0 = StreamHelper.ReadShort(stream); if (word0 >= 0) { byte byte0 = (byte)stream.ReadByte(); short word1 = StreamHelper.ReadShort(stream); Items = new ItemStack(word0, byte0, word1); } else { Items = null; } }
public void Read(NetworkStream stream) { Unknown1 = StreamHelper.ReadDouble(stream); Unknown2 = StreamHelper.ReadDouble(stream); Unknown3 = StreamHelper.ReadDouble(stream); Unknown4 = StreamHelper.ReadFloat(stream); Count = StreamHelper.ReadInt(stream); Unknown5 = new HashSet<ChunkPosition>(); for (int i = 0; i < Count; i++) { Unknown5.Add(new ChunkPosition( stream.ReadByte() + (int)Unknown1, stream.ReadByte() + (int)Unknown2, stream.ReadByte() + (int)Unknown3)); } }
public void Read(NetworkStream stream) { EntityID = StreamHelper.ReadInt(stream); VehicleType = (byte)stream.ReadByte(); X = StreamHelper.ReadInt(stream); Y = StreamHelper.ReadInt(stream); Z = StreamHelper.ReadInt(stream); }
public void Read(NetworkStream stream) { this.Version = StreamHelper.ReadInt(stream); //entity id this.Username = StreamHelper.ReadString(stream); //server name this.ServerPassword = StreamHelper.ReadString(stream); //motd this.MapSeed = StreamHelper.ReadLong(stream); //map seed this.Dimension = (byte)stream.ReadByte(); //dimension }
public void Read(NetworkStream stream) { X = StreamHelper.ReadDouble(stream); Y = StreamHelper.ReadDouble(stream); Stance = StreamHelper.ReadDouble(stream); Z = StreamHelper.ReadDouble(stream); OnGround = stream.ReadByte() != 0; }
public WebSocketFrame Read(NetworkStream stream) { // read the first byte. If the connection has been terminated abnormally then this would return an FF and we should exit byte byte1 = (byte)stream.ReadByte(); // this condition will happen if the connection has terminated unexpectedly if (!stream.DataAvailable && byte1 == 0xFF) { return new WebSocketFrame(true, WebSocketOpCode.ConnectionClose, new byte[0], false); } // process first byte byte finBitFlag = 0x80; byte opCodeFlag = 0x0F; bool isFinBitSet = (byte1 & finBitFlag) == finBitFlag; WebSocketOpCode opCode = (WebSocketOpCode)(byte1 & opCodeFlag); // read and process second byte byte byte2 = (byte)stream.ReadByte(); byte maskFlag = 0x80; bool isMaskBitSet = (byte2 & maskFlag) == maskFlag; uint len = ReadLength(byte2, stream); byte[] decodedPayload; // use the masking key to decode the data if needed if (isMaskBitSet) { const int maskKeyLen = 4; byte[] maskKey = BinaryReaderWriter.ReadExactly(maskKeyLen, stream); byte[] encodedPayload = BinaryReaderWriter.ReadExactly((int)len, stream); decodedPayload = new byte[len]; // apply the mask key for (int i = 0; i < encodedPayload.Length; i++) { decodedPayload[i] = (Byte)(encodedPayload[i] ^ maskKey[i % maskKeyLen]); } } else { decodedPayload = BinaryReaderWriter.ReadExactly((int)len, stream); } WebSocketFrame frame = new WebSocketFrame(isFinBitSet, opCode, decodedPayload, true); return frame; }
public void Read(NetworkStream stream) { ID = StreamHelper.ReadInt(stream); X = (byte)stream.ReadByte(); Y = StreamHelper.ReadInt(stream); Z = (byte)stream.ReadByte(); short word0 = StreamHelper.ReadShort(stream); if (word0 >= 0) { byte byte0 = (byte)stream.ReadByte(); short word1 = StreamHelper.ReadShort(stream); Direction = new ItemStack((int)word0, (int)byte0, (int)word1); } else { Direction = null; } }
/// <summary> /// Reads the text from the server/client /// </summary> /// <returns> /// The text. /// </returns> /// <param name='io'> /// Network stream for reading from the server/client. /// </param> public static String ReadTextTcp(NetworkStream io) { String line = ""; char ch; while((ch = (char)io.ReadByte()) != 0) line += ch; return line; }
public static byte[] BytesFill(NetworkStream Stream) { List<byte> Bytes = new List<byte>(); while (true) { int b = Stream.ReadByte(); if (b == -1) break; Bytes.Add((byte)b); } return Bytes.ToArray(); }
public void Read(NetworkStream stream) { X = StreamHelper.ReadInt(stream); Y = StreamHelper.ReadShort(stream); Z = StreamHelper.ReadInt(stream); XSize = stream.ReadByte() + 1; YSize = stream.ReadByte() + 1; ZSize = stream.ReadByte() + 1; int i = StreamHelper.ReadInt(stream); byte[] buffer = new byte[i]; buffer = StreamHelper.ReadBytes(stream, i); Chunk = new byte[(XSize * YSize * ZSize * 5) / 2]; using (Stream file = new MemoryStream(buffer)) using (Stream gzip = new Ionic.Zlib.ZlibStream(file, Ionic.Zlib.CompressionMode.Decompress)) using (MemoryStream memoryStream = new MemoryStream()) { CopyStream(gzip, memoryStream); Chunk = memoryStream.ToArray(); } }
public static byte Read(Socket sock) { try { NetworkStream str = new NetworkStream(sock); return (byte)str.ReadByte(); } catch (Exception e) { Console.WriteLine(e.Message); return 0; } }
public Session(string host, int port, string username, string pw) { socket = new TcpClient(host, port); stream = socket.GetStream(); ehost = host; string ts = Receive(); Send(username); Send(MD5(MD5(pw) + ts)); if (stream.ReadByte() != 0) { throw new IOException("Access denied."); } }
public static string GetNetworkPath(System.Net.Sockets.NetworkStream nstm, string host) { #if VARIABLE_NETWORK_PATHS nstm.WriteByte((byte)'d'); // Get current directory. if ((int)'+' != nstm.ReadByte()) { throw new Exception("GetNetworkPath failure (service didn't report success)"); } return(LocalPathToNetworkPath(XContent.ReceiveXString(nstm, null), host)); #else return(LocalPathToNetworkPath(_netpath, host)); #endif }
internal static String readSmallString(NetworkStream stream) { byte size = (byte)stream.ReadByte(); String s = ""; for (int i = 0; i < size; i++ ) { s += Convert.ToChar((byte)stream.ReadByte()); } return s; }
internal static int readInt(NetworkStream stream) { return (stream.ReadByte() << 24) | (stream.ReadByte() << 16) | (stream.ReadByte() << 8) | (stream.ReadByte()); }
internal static float readFloat(NetworkStream stream) { return BitConverter.ToSingle(new byte[] { (byte)stream.ReadByte(), (byte)stream.ReadByte(), (byte)stream.ReadByte(), (byte)stream.ReadByte() }, 0); }
internal static byte readByte(NetworkStream stream) { return (byte)stream.ReadByte(); }
public static Packet readPacket(NetworkStream stream) { byte packetId = (byte)stream.ReadByte(); return readPacket(stream, packetId); }