private void OnHttpResponse(string rawData) { byte[] data = Convert.FromBase64String(rawData); ByteArray byteArray = new ByteArray(); ByteArray byteArray2 = new ByteArray(); byteArray.WriteBytes(data, 0, 16); byteArray2.WriteBytes(data, 16, 16); sfs.GetSocketEngine().CryptoKey = new CryptoKey(byteArray2, byteArray); Hashtable hashtable = new Hashtable(); hashtable["success"] = true; sfs.DispatchEvent(new SFSEvent(SFSEvent.CRYPTO_INIT, hashtable)); }
private void Log(LogLevel level, string message) { if (level >= loggingLevel) { if (enableConsoleTrace) { Console.WriteLine(string.Concat("[SFS - ", level, "] ", message)); } if (enableEventDispatching && smartFox != null) { Hashtable hashtable = new Hashtable(); hashtable.Add("message", message); LoggerEvent evt = new LoggerEvent(level, hashtable); smartFox.DispatchEvent(evt); } } }
private void OnUDPData(byte[] bt) { //Discarded unreachable code: IL_014c ByteArray byteArray = new ByteArray(bt); if (byteArray.BytesAvailable < 4) { log.Warn("Too small UDP packet. Len: " + byteArray.Length); return; } if (sfs.Debug) { log.Info("UDP Data Read: " + DefaultObjectDumpFormatter.HexDump(byteArray)); } byte b = byteArray.ReadByte(); bool flag = (b & 0x20) > 0; bool flag2 = (b & 0x40) > 0; short num = byteArray.ReadShort(); if (num != byteArray.BytesAvailable) { log.Warn("Insufficient UDP data. Expected: " + num + ", got: " + byteArray.BytesAvailable); return; } byte[] buf = byteArray.ReadBytes(byteArray.BytesAvailable); ByteArray byteArray2 = new ByteArray(buf); if (flag2) { try { packetEncrypter.Decrypt(byteArray2); } catch (Exception ex) { log.Warn("UDP data decryption failed due to error: " + ex.Message + " " + ex.StackTrace); return; } } if (flag) { byteArray2.Uncompress(); } ISFSObject iSFSObject = SFSObject.NewFromBinaryData(byteArray2); if (iSFSObject.ContainsKey("h")) { if (!initSuccess) { StopTimer(); locked = false; initSuccess = true; Hashtable hashtable = new Hashtable(); hashtable["success"] = true; sfs.DispatchEvent(new SFSEvent(SFSEvent.UDP_INIT, hashtable)); } } else { sfs.GetSocketEngine().IoHandler.Codec.OnPacketRead(iSFSObject); } }