public void BossSimple() { TcpClient _TcpClient = new TcpClient(ip, port); _Socket = _TcpClient.Client; _NetworkStream = new NetworkStream(_Socket); Flap hello = new Flap { _ICQ = this }.Receive(); //receive hello Flap _Flap1 = new Flap { _ICQ = this, ch = 1 }; _Flap1._data.Write(new byte[] { 0, 0, 0, 1 }); _Flap1._Tvls.Add(new Tvl { data = _Cookie, type = 6 }); _Flap1.WriteTvl().Send(); Flap _Flap2 = new Flap { _ICQ = this }.Receive().ReadSnac(); Flap _Flap3 = new Flap { _ICQ = this }; _Flap3.ch = 2; _Flap3._Snac.ID1 = 1; _Flap3._Snac.ID2 = 2; _Flap3._Snac.flag1 = _Flap3._Snac.flag2 = 0; _Flap3.WriteSnac();//.Write(); while (_Flap2._data.Position != _Flap2._data.Length) { UInt16 a = _Flap2._data.ReadUInt16(); _Flap3._data.WriteUint16(a); _Flap3._data.Write("00 01 01 10 04 7B".Hex()); } _Flap3.Send(); Flap _Flap4 = new Flap { _ICQ = this }; _Flap4.Receive().ReadSnac(); if (_Flap4._Snac.ID1 != 11 || _Flap4._Snac.ID2 != 2) { throw new Exception(); } Thread.Sleep(1000); }
public void SendMessage(Im im) { try { if (_ConnectionStatus != ConnectionStatus.Connected) { throw new Exception("Not Connected"); } Flap _Flap = new Flap { _ICQ = this }; _Flap.ch = 2; _Flap._Snac.ID1 = 4; _Flap._Snac.ID2 = 6; _Flap.WriteSnac(); _Dictionary.Add(_Flap._Snac.req, im); _Flap._data.Write("00 00 00 00 00 00 00 00 00 01".Hex()); byte[] sendto = ASCIIEncoding.ASCII.GetBytes(im.uin); _Flap._data.WriteByte((byte)sendto.Length); _Flap._data.Write(sendto); _Flap._data.Write(new byte[] { 0, 6, 0, 0 }); Tvl _Tvl02 = new Tvl() { data = new byte[] { 05, 01, 00, 02, 01, 01 }, type = 2 }; Tvl _Tvl0101 = new Tvl() { type = 257, data = ("\0\0\0\0" + im.msg).ToBytes() }; _Tvl02.data = _Tvl02.data.Join(_Tvl0101.ToBytes()); _Flap._Tvls.Add(_Tvl02); _Flap.WriteTvl().Send(); im.Status = MessageStatus.Sending; im._DateTime = DateTime.Now; } catch (IOException) { Trace2(_uin + "Error msg send failed"); } }