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); }
private void StartListen() { try { try { Connect(); } catch (IOException) { throw new ExceptionB("conn error2"); } catch (SocketException) { throw new ExceptionB("conn error2"); } Thread.Sleep(2000); _ConnectionStatus = ConnectionStatus.Connected; Trace2(Trace("Connected " + _uin)); while (true) { Flap _Flap = new Flap { _ICQ = this }; _Flap.Receive(); Trace("FlapReceived"); Trace(_Flap._data.ToArray().ToHex()); Trace("Snac Type Of" + _Flap.ch); switch (_Flap.ch) { default: break; case 2: { _Flap.ReadSnac(); if (_Flap._Snac.ID1 == 4) { Im _Im = null; if (_Dictionary.Keys.Contains(_Flap._Snac.req)) { _Im = _Dictionary[_Flap._Snac.req]; } if (_Flap._Snac.ID2 == 7) //message { ReadMsg1(_Flap); } if (_Flap._Snac.ID2 == 12 && _Im != null) //accepted { _Im.Status = MessageStatus.AcceptedForDelivery; OnMessageStatusChanged(_Im); _Dictionary.Remove(_Flap._Snac.req); } if (_Flap._Snac.ID2 == 1 && _Im != null) { _Im.Status = MessageStatus.UnknownError; _Dictionary.Remove(_Flap._Snac.req); int errorcode = _Flap._data.ReadUInt16(); _Flap.ReadTvl(); int subcode = 0; Tvl _Tvl = _Flap.GetTvl(0x0008); if (_Tvl != null) { subcode = BitConverter.ToUInt16(_Tvl.data.ReverseA(2), 0); } switch (errorcode) { case 0x0004: _Im.Status = MessageStatus.BuddyOffline; break; case 0x0010: _Im.Status = MessageStatus.BuddyBlocked; break; } switch (subcode) { case 0x000E: _Im.Status = MessageStatus.OfflineMessagesNotSupported; break; case 0x000F: _Im.Status = MessageStatus.OfflineStorageFull; break; } OnMessageStatusChanged(_Im); } } } break; } } } catch (ExecutionEngineException) { } catch (IOException e) { Trace(e); Thread.Sleep(1000); _ConnectionStatus = ConnectionStatus.Kicked; } catch (SocketException e) { Trace(e); Thread.Sleep(1000); _ConnectionStatus = ConnectionStatus.Kicked; } catch (ExceptionB e) { Trace(e); Thread.Sleep(15000); if (ConnectionStatus.LoginError == _oldConnectionStatus) { Thread.Sleep(16 * 1000 * 60); } _ConnectionStatus = ConnectionStatus.LoginError; } errors++; }