Commit 37b2bb1f authored by Scott Stamp's avatar Scott Stamp

I honestly don't even remember what I changed

But it dumps structures now, sometimes, so w/e. Have fun.
parent 83f2b6f4
......@@ -175,6 +175,11 @@ namespace TanjiCore.Intercept.Network.Protocol
return value;
}
public byte ReadByte(ref int position)
{
return ReadBytes(1, ref position)[0];
}
public byte[] ReadBytes(int length)
{
return ReadBytes(length, ref _position);
......
......@@ -189,8 +189,9 @@ namespace TanjiCore.Web.Middleware.Proxy
Program.Game.DisableHostChecks();
Program.Game.InjectKeyShouter(4001);
Program.Game.GenerateMessageHashes();
CompressionKind compression = CompressionKind.ZLIB;
CompressionKind compression = CompressionKind.None;
//#if DEBUG
//compression = CompressionKind.None;
//#endif
......
......@@ -52,12 +52,74 @@ namespace TanjiCore.Web
public void PacketOutgoing(object sender, DataInterceptedEventArgs e)
{
SendMessage("outgoing", $"Outgoing: [{e.Packet.Header}]: {e.Packet.ToString()}").Wait();
var message = Program.Game.OutMessages[e.Packet.Header];
var structure = "\r\n";
int position = 0;
if (message.Structure != null)
{
foreach(string valueType in message.Structure)
{
switch (valueType.ToLower())
{
case "int":
structure += ("{i:" + e.Packet.ReadInteger(ref position) + "}");
break;
case "string":
structure += ("{s:" + e.Packet.ReadString(ref position) + "}");
break;
case "double":
structure += ("{d:" + e.Packet.ReadDouble(ref position) + "}");
break;
case "byte":
structure += ("{b:" + e.Packet.ReadByte(ref position) + "}");
break;
case "boolean":
structure += ("{b:" + e.Packet.ReadBoolean(ref position) + "}");
break;
}
}
}
if (structure != "\r\n") structure += "\r\n";
SendMessage("outgoing", $"[{message.Hash}]" + structure + $"Incoming: [{e.Packet.Header}]: {e.Packet.ToString()}").Wait();
}
public void PacketIncoming(object sender, DataInterceptedEventArgs e)
{
SendMessage("incoming", $"Incoming: [{e.Packet.Header}]: {e.Packet.ToString()}").Wait();
var message = Program.Game.InMessages[e.Packet.Header];
var structure = "\r\n";
int position = 0;
if (message.Structure != null)
{
foreach (string valueType in message.Structure)
{
switch (valueType.ToLower())
{
case "int":
structure += ("{i:" + e.Packet.ReadInteger(ref position) + "}");
break;
case "string":
structure += ("{s:" + e.Packet.ReadString(ref position) + "}");
break;
case "double":
structure += ("{d:" + e.Packet.ReadDouble(ref position) + "}");
break;
case "byte":
structure += ("{b:" + e.Packet.ReadByte(ref position) + "}");
break;
case "boolean":
structure += ("{b:" + e.Packet.ReadBoolean(ref position) + "}");
break;
}
}
}
if (structure != "\r\n") structure += "\r\n";
SendMessage("incoming", $"[{message.Hash}]" + structure + $"Incoming: [{e.Packet.Header}]: {e.Packet.ToString()}").Wait();
}
}
}
\ No newline at end of file
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
else if(typeof define === 'function' && define.amd)
define("WebSocketManager", [], factory);
else if(typeof exports === 'object')
exports["WebSocketManager"] = factory();
else
root["WebSocketManager"] = factory();
})(this, function() {
return /******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])
/******/ return installedModules[moduleId].exports;
/******/
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ exports: {},
/******/ id: moduleId,
/******/ loaded: false
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.loaded = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(1);
/***/ },
/* 1 */
/***/ function(module, exports, __webpack_require__) {
"use strict";
var InvocationDescriptor_1 = __webpack_require__(2);
var Message_1 = __webpack_require__(3);
var Connection = (function () {
function Connection(url, enableLogging) {
var _this = this;
if (enableLogging === void 0) { enableLogging = false; }
this.enableLogging = false;
this.clientMethods = {};
this.connectionMethods = {};
this.url = url;
this.enableLogging = enableLogging;
this.connectionMethods['onConnected'] = function () {
if (_this.enableLogging) {
console.log('Connected! connectionId: ' + _this.connectionId);
}
};
this.connectionMethods['onDisconnected'] = function () {
if (_this.enableLogging) {
console.log('Connection closed from: ' + _this.url);
}
};
this.connectionMethods['onOpen'] = function (socketOpenedEvent) {
if (_this.enableLogging) {
console.log('WebSockets connection opened!');
}
};
}
Connection.prototype.start = function () {
var _this = this;
this.socket = new WebSocket(this.url);
this.socket.onopen = function (event) {
_this.connectionMethods['onOpen'].apply(_this, event);
};
this.socket.onmessage = function (event) {
_this.message = JSON.parse(event.data);
if (_this.message.messageType == Message_1.MessageType.Text) {
if (_this.enableLogging) {
console.log('Text message received. Message: ' + _this.message.data);
}
}
else if (_this.message.messageType == Message_1.MessageType.MethodInvocation) {
var invocationDescriptor = JSON.parse(_this.message.data);
_this.clientMethods[invocationDescriptor.methodName].apply(_this, invocationDescriptor.arguments);
}
else if (_this.message.messageType == Message_1.MessageType.ConnectionEvent) {
_this.connectionId = _this.message.data;
_this.connectionMethods['onConnected'].apply(_this);
}
};
this.socket.onclose = function (event) {
_this.connectionMethods['onDisconnected'].apply(_this);
};
this.socket.onerror = function (event) {
if (_this.enableLogging) {
console.log('Error data: ' + event.error);
}
};
};
Connection.prototype.invoke = function (methodName) {
var args = [];
for (var _i = 1; _i < arguments.length; _i++) {
args[_i - 1] = arguments[_i];
}
var invocationDescriptor = new InvocationDescriptor_1.InvocationDescriptor(methodName, args);
if (this.enableLogging) {
console.log(invocationDescriptor);
}
this.socket.send(JSON.stringify(invocationDescriptor));
};
return Connection;
}());
exports.Connection = Connection;
/***/ },
/* 2 */
/***/ function(module, exports) {
"use strict";
var InvocationDescriptor = (function () {
function InvocationDescriptor(methodName, args) {
this.methodName = methodName;
this.arguments = args;
}
return InvocationDescriptor;
}());
exports.InvocationDescriptor = InvocationDescriptor;
/***/ },
/* 3 */
/***/ function(module, exports) {
"use strict";
(function (MessageType) {
MessageType[MessageType["Text"] = 0] = "Text";
MessageType[MessageType["MethodInvocation"] = 1] = "MethodInvocation";
MessageType[MessageType["ConnectionEvent"] = 2] = "ConnectionEvent";
})(exports.MessageType || (exports.MessageType = {}));
var MessageType = exports.MessageType;
var Message = (function () {
function Message() {
}
return Message;
}());
exports.Message = Message;
/***/ }
/******/ ])
});
;
//# sourceMappingURL=WebSocketManager.js.map
\ No newline at end of file
!function (b, c) { "object" == typeof exports && "object" == typeof module ? module.exports = c() : "function" == typeof define && define.amd ? define("WebSocketManager", [], c) : "object" == typeof exports ? exports.WebSocketManager = c() : b.WebSocketManager = c() }(this, function () { return function (a) { function c(d) { if (b[d]) return b[d].exports; var e = b[d] = { exports: {}, id: d, loaded: !1 }; return a[d].call(e.exports, e, e.exports, c), e.loaded = !0, e.exports } var b = {}; return c.m = a, c.c = b, c.p = "", c(0) }([function (a, b, c) { a.exports = c(1) }, function (a, b, c) { "use strict"; var d = c(2), e = c(3), f = function () { function a(a, b) { var c = this; void 0 === b && (b = !1), this.enableLogging = !1, this.clientMethods = {}, this.connectionMethods = {}, this.url = a, this.enableLogging = b, this.connectionMethods.onConnected = function () { c.enableLogging && console.log("Connected! connectionId: " + c.connectionId) }, this.connectionMethods.onDisconnected = function () { c.enableLogging && console.log("Connection closed from: " + c.url) }, this.connectionMethods.onOpen = function (a) { c.enableLogging && console.log("WebSockets connection opened!") } } return a.prototype.start = function () { var a = this; this.socket = new WebSocket(this.url), this.socket.onopen = function (b) { a.connectionMethods.onOpen.apply(a, b) }, this.socket.onmessage = function (b) { if (a.message = JSON.parse(b.data), a.message.messageType == e.MessageType.Text) a.enableLogging && console.log("Text message received. Message: " + a.message.data); else if (a.message.messageType == e.MessageType.MethodInvocation) { var c = JSON.parse(a.message.data); a.clientMethods[c.methodName].apply(a, c.arguments) } else a.message.messageType == e.MessageType.ConnectionEvent && (a.connectionId = a.message.data, a.connectionMethods.onConnected.apply(a)) }, this.socket.onclose = function (b) { a.connectionMethods.onDisconnected.apply(a) }, this.socket.onerror = function (b) { a.enableLogging && console.log("Error data: " + b.error) } }, a.prototype.invoke = function (a) { for (var b = [], c = 1; c < arguments.length; c++)b[c - 1] = arguments[c]; var e = new d.InvocationDescriptor(a, b); this.enableLogging && console.log(e), this.socket.send(JSON.stringify(e)) }, a }(); b.Connection = f }, function (a, b) { "use strict"; var c = function () { function a(a, b) { this.methodName = a, this.arguments = b } return a }(); b.InvocationDescriptor = c }, function (a, b) { "use strict"; !function (a) { a[a.Text = 0] = "Text", a[a.MethodInvocation = 1] = "MethodInvocation", a[a.ConnectionEvent = 2] = "ConnectionEvent" }(b.MessageType || (b.MessageType = {})); var d = (b.MessageType, function () { function a() { } return a }()); b.Message = d }]) });
\ No newline at end of file
......@@ -16,25 +16,4 @@ connection.clientMethods["receiveMessage"] = (direction, message) => {
textArea.value = message + "\r\n" + textArea.value;
};
function insertAtCursor(myField, myValue) {
//IE support
if (document.selection) {
myField.focus();
sel = document.selection.createRange();
sel.text = myValue;
}
//MOZILLA and others
else if (myField.selectionStart || myField.selectionStart == '0') {
var startPos = myField.selectionStart;
var endPos = myField.selectionEnd;
myField.value = myField.value.substring(0, startPos)
+ myValue
+ myField.value.substring(endPos, myField.value.length);
myField.selectionStart = startPos + myValue.length;
myField.selectionEnd = startPos + myValue.length;
} else {
myField.value += myValue;
}
}
connection.start();
\ No newline at end of file
......@@ -45,7 +45,7 @@ namespace WebSocketManager
catch (WebSocketException)
{
throw; //let's not swallow any exception for now
//throw; //let's not swallow any exception for now fuck you
}
return;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment