Commit e6e90691 authored by nanahira's avatar nanahira

Merge branch 'cloudrep-chat'

parents 829ee179 a180954a
// Generated by CoffeeScript 2.5.1
// Generated by CoffeeScript 2.6.1
(function() {
var Replay, ReplayReader, fs, lzma, replayHeader;
......
......@@ -156,16 +156,23 @@ class YGOProMessagesHelper {
}
return sendBuffer;
}
sendMessage(socket, protostr, info) {
const sendBuffer = this.prepareMessage(protostr, info);
socket.write(sendBuffer);
}
sendMessageAsync(socket, protostr, info) {
const sendBuffer = this.prepareMessage(protostr, info);
send(socket, buffer) {
return new Promise(done => {
socket.write(sendBuffer, done);
if (socket['isWs']) {
const ws = socket;
// @ts-ignore
ws.send(buffer, {}, done);
}
else {
const sock = socket;
sock.write(buffer, done);
}
});
}
sendMessage(socket, protostr, info) {
const sendBuffer = this.prepareMessage(protostr, info);
return this.send(socket, sendBuffer);
}
addHandler(protostr, handler, synchronous, priority) {
if (priority < 0 || priority > 4) {
throw "Invalid priority: " + priority;
......
......@@ -196,16 +196,22 @@ export class YGOProMessagesHelper {
return sendBuffer;
}
sendMessage(socket: net.Socket, protostr: string, info?: string | Buffer | any) {
const sendBuffer = this.prepareMessage(protostr, info);
socket.write(sendBuffer);
send(socket: net.Socket | WebSocket, buffer: Buffer) {
return new Promise<Error | undefined>(done => {
if (socket['isWs']) {
const ws = socket as WebSocket;
// @ts-ignore
ws.send(buffer, {}, done);
} else {
const sock = socket as net.Socket;
sock.write(buffer, done);
}
})
}
sendMessageAsync(socket: net.Socket, protostr: string, info?: string | Buffer | any): Promise<Error> {
sendMessage(socket: net.Socket | WebSocket, protostr: string, info?: string | Buffer | any): Promise<Error> {
const sendBuffer = this.prepareMessage(protostr, info);
return new Promise(done => {
socket.write(sendBuffer, done);
});
return this.send(socket, sendBuffer);
}
addHandler(protostr: string, handler: (buffer: Buffer, info: any, datas: Buffer[], params: any) => Promise<boolean | string>, synchronous: boolean, priority: number) {
......
......@@ -196,6 +196,15 @@
"banCount": 0,
"ttl": 600
},
"neos": {
"enabled": false,
"port": 7977,
"trusted_proxies": [
"127.0.0.1/8",
"::1/128"
],
"ip_header": "x-forwarded-for"
},
"test_mode": {
"watch_public_hand": false,
"no_connect_count_limit": false,
......
......@@ -15,6 +15,7 @@
"deepmerge": "^4.2.2",
"formidable": "^1.2.6",
"geoip-country-lite": "^1.0.0",
"ip6addr": "^0.2.5",
"jszip": "^3.5.0",
"load-json-file": "^6.2.0",
"lzma": "^2.3.2",
......@@ -35,6 +36,7 @@
},
"devDependencies": {
"@types/bunyan": "^1.8.8",
"@types/ip6addr": "^0.2.3",
"@types/node": "^17.0.19",
"@types/underscore": "^1.11.4",
"@types/ws": "^8.5.3",
......@@ -79,6 +81,12 @@
"@types/node": "*"
}
},
"node_modules/@types/ip6addr": {
"version": "0.2.3",
"resolved": "https://registry.npmjs.org/@types/ip6addr/-/ip6addr-0.2.3.tgz",
"integrity": "sha512-oe7hzc+P9DU6+gql8+bLKuUf4WL4aakyCSXZMZq2cjhhGK75qYwH1zJ4s94XOlnb4cAhrGKwnbrmMBaqDK8+Ww==",
"dev": true
},
"node_modules/@types/node": {
"version": "17.0.19",
"resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.19.tgz",
......@@ -1187,6 +1195,34 @@
"node": "*"
}
},
"node_modules/ip6addr": {
"version": "0.2.5",
"resolved": "https://registry.npmjs.org/ip6addr/-/ip6addr-0.2.5.tgz",
"integrity": "sha512-9RGGSB6Zc9Ox5DpDGFnJdIeF0AsqXzdH+FspCfPPaU/L/4tI6P+5lIoFUFm9JXs9IrJv1boqAaNCQmoDADTSKQ==",
"dependencies": {
"assert-plus": "^1.0.0",
"jsprim": "^2.0.2"
}
},
"node_modules/ip6addr/node_modules/json-schema": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.4.0.tgz",
"integrity": "sha512-es94M3nTIfsEPisRafak+HDLfHXnKBhV3vU5eqPcS3flIWqcxJWgXHXiey3YrpaNsanY5ei1VoYEbOzijuq9BA=="
},
"node_modules/ip6addr/node_modules/jsprim": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/jsprim/-/jsprim-2.0.2.tgz",
"integrity": "sha512-gqXddjPqQ6G40VdnI6T6yObEC+pDNvyP95wdQhkWkg7crHH3km5qP1FsOXEkzEQwnz6gz5qGTn1c2Y52wP3OyQ==",
"engines": [
"node >=0.6.0"
],
"dependencies": {
"assert-plus": "1.0.0",
"extsprintf": "1.3.0",
"json-schema": "0.4.0",
"verror": "1.10.0"
}
},
"node_modules/is-arrayish": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz",
......@@ -3112,6 +3148,12 @@
"@types/node": "*"
}
},
"@types/ip6addr": {
"version": "0.2.3",
"resolved": "https://registry.npmjs.org/@types/ip6addr/-/ip6addr-0.2.3.tgz",
"integrity": "sha512-oe7hzc+P9DU6+gql8+bLKuUf4WL4aakyCSXZMZq2cjhhGK75qYwH1zJ4s94XOlnb4cAhrGKwnbrmMBaqDK8+Ww==",
"dev": true
},
"@types/node": {
"version": "17.0.19",
"resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.19.tgz",
......@@ -3954,6 +3996,33 @@
"resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz",
"integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw=="
},
"ip6addr": {
"version": "0.2.5",
"resolved": "https://registry.npmjs.org/ip6addr/-/ip6addr-0.2.5.tgz",
"integrity": "sha512-9RGGSB6Zc9Ox5DpDGFnJdIeF0AsqXzdH+FspCfPPaU/L/4tI6P+5lIoFUFm9JXs9IrJv1boqAaNCQmoDADTSKQ==",
"requires": {
"assert-plus": "^1.0.0",
"jsprim": "^2.0.2"
},
"dependencies": {
"json-schema": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.4.0.tgz",
"integrity": "sha512-es94M3nTIfsEPisRafak+HDLfHXnKBhV3vU5eqPcS3flIWqcxJWgXHXiey3YrpaNsanY5ei1VoYEbOzijuq9BA=="
},
"jsprim": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/jsprim/-/jsprim-2.0.2.tgz",
"integrity": "sha512-gqXddjPqQ6G40VdnI6T6yObEC+pDNvyP95wdQhkWkg7crHH3km5qP1FsOXEkzEQwnz6gz5qGTn1c2Y52wP3OyQ==",
"requires": {
"assert-plus": "1.0.0",
"extsprintf": "1.3.0",
"json-schema": "0.4.0",
"verror": "1.10.0"
}
}
}
},
"is-arrayish": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz",
......
......@@ -17,6 +17,7 @@
"deepmerge": "^4.2.2",
"formidable": "^1.2.6",
"geoip-country-lite": "^1.0.0",
"ip6addr": "^0.2.5",
"jszip": "^3.5.0",
"load-json-file": "^6.2.0",
"lzma": "^2.3.2",
......@@ -46,6 +47,7 @@
},
"devDependencies": {
"@types/bunyan": "^1.8.8",
"@types/ip6addr": "^0.2.3",
"@types/node": "^17.0.19",
"@types/underscore": "^1.11.4",
"@types/ws": "^8.5.3",
......
// Generated by CoffeeScript 2.5.1
// Generated by CoffeeScript 2.6.1
(function() {
/*
Main script of new dashboard account system.
......
This diff is collapsed.
This diff is collapsed.
......@@ -59,16 +59,22 @@ translateHandler = (handler) ->
return @helper.sendMessage(socket, "CTOS_#{proto}", info)
#util
@stoc_send_chat = (client, msg, player = 8)->
if !client
console.log "err stoc_send_chat"
return
@split_chat_lines = (msg, player, lang) ->
lines = []
for line in _.lines(msg)
if player>=10
line="[Server]: "+line
for o,r of @i18nR[client.lang]
for o,r of @i18nR[lang]
line=line.replace(r.regex, r.text)
@stoc_send client, 'CHAT', {
lines.push(line)
return lines
@stoc_send_chat = (client, msg, player = 8)->
if !client
console.log "err stoc_send_chat"
return
for line in @split_chat_lines(msg, player, client.lang)
await @stoc_send client, 'CHAT', {
player: player
msg: line
}
......@@ -82,6 +88,7 @@ translateHandler = (handler) ->
@stoc_send_chat(client, msg, player) if client
for client in room.watchers
@stoc_send_chat(client, msg, player) if client
room.recordChatMessage(msg, player)
return
@stoc_send_hint_card_to_room = (room, card)->
......@@ -105,8 +112,8 @@ translateHandler = (handler) ->
return
@stoc_die = (client, msg)->
@stoc_send_chat(client, msg, @constants.COLORS.RED)
@stoc_send client, 'ERROR_MSG', {
await @stoc_send_chat(client, msg, @constants.COLORS.RED)
await @stoc_send client, 'ERROR_MSG', {
msg: 1
code: 9
} if client
......
// Generated by CoffeeScript 2.5.1
// Generated by CoffeeScript 2.6.1
(function() {
var Struct, YGOProMessagesHelper, _, loadJSON, translateHandler;
......@@ -95,24 +95,35 @@
};
//util
this.stoc_send_chat = function(client, msg, player = 8) {
var i, len, line, o, r, ref, ref1;
if (!client) {
console.log("err stoc_send_chat");
return;
}
this.split_chat_lines = function(msg, player, lang) {
var i, len, line, lines, o, r, ref, ref1;
lines = [];
ref = _.lines(msg);
for (i = 0, len = ref.length; i < len; i++) {
line = ref[i];
if (player >= 10) {
line = "[Server]: " + line;
}
ref1 = this.i18nR[client.lang];
ref1 = this.i18nR[lang];
for (o in ref1) {
r = ref1[o];
line = line.replace(r.regex, r.text);
}
this.stoc_send(client, 'CHAT', {
lines.push(line);
}
return lines;
};
this.stoc_send_chat = async function(client, msg, player = 8) {
var i, len, line, ref;
if (!client) {
console.log("err stoc_send_chat");
return;
}
ref = this.split_chat_lines(msg, player, client.lang);
for (i = 0, len = ref.length; i < len; i++) {
line = ref[i];
await this.stoc_send(client, 'CHAT', {
player: player,
msg: line
});
......@@ -139,6 +150,7 @@
this.stoc_send_chat(client, msg, player);
}
}
room.recordChatMessage(msg, player);
};
this.stoc_send_hint_card_to_room = function(room, card) {
......@@ -173,10 +185,10 @@
}
};
this.stoc_die = function(client, msg) {
this.stoc_send_chat(client, msg, this.constants.COLORS.RED);
this.stoc_die = async function(client, msg) {
await this.stoc_send_chat(client, msg, this.constants.COLORS.RED);
if (client) {
this.stoc_send(client, 'ERROR_MSG', {
await this.stoc_send(client, 'ERROR_MSG', {
msg: 1,
code: 9
});
......
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