Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
S
srvpro
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
3
Merge Requests
3
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
srvpro
Commits
1157a4bf
Commit
1157a4bf
authored
Sep 08, 2016
by
mercury233
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update buffer
parent
c47548f3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
18 deletions
+30
-18
ygopro-server.coffee
ygopro-server.coffee
+14
-8
ygopro-server.js
ygopro-server.js
+16
-10
No files found.
ygopro-server.coffee
View file @
1157a4bf
...
...
@@ -690,7 +690,7 @@ net.createServer (client) ->
client
.
write
replay_buffer
setTimeout
(()
->
client
.
destroy
()
return
),
1
000
return
),
5
000
return
return
...
...
@@ -699,15 +699,15 @@ net.createServer (client) ->
client
.
pre_establish_buffers
=
new
Array
()
client
.
on
'data'
,
(
data
)
->
client
.
on
'data'
,
(
ctos_buffer
)
->
if
client
.
is_post_watcher
room
=
ROOM_all
[
client
.
rid
]
room
.
watcher
.
write
data
if
room
room
.
watcher
.
write
ctos_buffer
if
room
else
ctos_buffer
=
new
Buffer
(
0
)
#
ctos_buffer = new Buffer(0)
ctos_message_length
=
0
ctos_proto
=
0
ctos_buffer
=
Buffer
.
concat
([
ctos_buffer
,
data
],
ctos_buffer
.
length
+
data
.
length
)
#buffer的错误使用方式,好孩子不要学
#
ctos_buffer = Buffer.concat([ctos_buffer, data], ctos_buffer.length + data.length) #buffer的错误使用方式,好孩子不要学
datas
=
[]
...
...
@@ -718,11 +718,13 @@ net.createServer (client) ->
if
ctos_buffer
.
length
>=
2
ctos_message_length
=
ctos_buffer
.
readUInt16LE
(
0
)
else
log
.
warn
(
"bad ctos_buffer length"
,
client
.
ip
)
unless
ctos_buffer
.
length
==
0
break
else
if
ctos_proto
==
0
if
ctos_buffer
.
length
>=
3
ctos_proto
=
ctos_buffer
.
readUInt8
(
2
)
else
log
.
warn
(
"bad ctos_proto length"
,
client
.
ip
)
break
else
if
ctos_buffer
.
length
>=
2
+
ctos_message_length
...
...
@@ -743,6 +745,7 @@ net.createServer (client) ->
ctos_message_length
=
0
ctos_proto
=
0
else
log
.
warn
(
"bad ctos_message length"
,
client
.
ip
)
break
looplimit
++
...
...
@@ -765,11 +768,11 @@ net.createServer (client) ->
return
# 服务端到客户端(stoc)
server
.
on
'data'
,
(
data
)
->
stoc_buffer
=
new
Buffer
(
0
)
server
.
on
'data'
,
(
stoc_buffer
)
->
#
stoc_buffer = new Buffer(0)
stoc_message_length
=
0
stoc_proto
=
0
stoc_buffer
=
Buffer
.
concat
([
stoc_buffer
,
data
],
stoc_buffer
.
length
+
data
.
length
)
#buffer的错误使用方式,好孩子不要学
#
stoc_buffer = Buffer.concat([stoc_buffer, data], stoc_buffer.length + data.length) #buffer的错误使用方式,好孩子不要学
#unless ygopro.stoc_follows[stoc_proto] and ygopro.stoc_follows[stoc_proto].synchronous
#client.write data
...
...
@@ -782,11 +785,13 @@ net.createServer (client) ->
if
stoc_buffer
.
length
>=
2
stoc_message_length
=
stoc_buffer
.
readUInt16LE
(
0
)
else
log
.
warn
(
"bad stoc_buffer length"
,
client
.
ip
)
unless
stoc_buffer
.
length
==
0
break
else
if
stoc_proto
==
0
if
stoc_buffer
.
length
>=
3
stoc_proto
=
stoc_buffer
.
readUInt8
(
2
)
else
log
.
warn
(
"bad stoc_proto length"
,
client
.
ip
)
break
else
if
stoc_buffer
.
length
>=
2
+
stoc_message_length
...
...
@@ -811,6 +816,7 @@ net.createServer (client) ->
stoc_message_length
=
0
stoc_proto
=
0
else
log
.
warn
(
"bad stoc_message length"
,
client
.
ip
)
break
looplimit
++
...
...
ygopro-server.js
View file @
1157a4bf
...
...
@@ -891,23 +891,21 @@
client
.
write
(
replay_buffer
);
setTimeout
((
function
()
{
client
.
destroy
();
}),
1
000
);
}),
5
000
);
});
};
}
client
.
pre_establish_buffers
=
new
Array
();
client
.
on
(
'
data
'
,
function
(
data
)
{
var
b
,
bad_ip_count
,
buffer
,
cancel
,
ctos_
buffer
,
ctos_
message_length
,
ctos_proto
,
datas
,
k
,
l
,
len
,
len1
,
looplimit
,
room
,
struct
;
client
.
on
(
'
data
'
,
function
(
ctos_buffer
)
{
var
b
,
bad_ip_count
,
buffer
,
cancel
,
ctos_message_length
,
ctos_proto
,
datas
,
k
,
l
,
len
,
len1
,
looplimit
,
room
,
struct
;
if
(
client
.
is_post_watcher
)
{
room
=
ROOM_all
[
client
.
rid
];
if
(
room
)
{
room
.
watcher
.
write
(
data
);
room
.
watcher
.
write
(
ctos_buffer
);
}
}
else
{
ctos_buffer
=
new
Buffer
(
0
);
ctos_message_length
=
0
;
ctos_proto
=
0
;
ctos_buffer
=
Buffer
.
concat
([
ctos_buffer
,
data
],
ctos_buffer
.
length
+
data
.
length
);
datas
=
[];
looplimit
=
0
;
while
(
true
)
{
...
...
@@ -915,12 +913,16 @@
if
(
ctos_buffer
.
length
>=
2
)
{
ctos_message_length
=
ctos_buffer
.
readUInt16LE
(
0
);
}
else
{
if
(
ctos_buffer
.
length
!==
0
)
{
log
.
warn
(
"
bad ctos_buffer length
"
,
client
.
ip
);
}
break
;
}
}
else
if
(
ctos_proto
===
0
)
{
if
(
ctos_buffer
.
length
>=
3
)
{
ctos_proto
=
ctos_buffer
.
readUInt8
(
2
);
}
else
{
log
.
warn
(
"
bad ctos_proto length
"
,
client
.
ip
);
break
;
}
}
else
{
...
...
@@ -946,6 +948,7 @@
ctos_message_length
=
0
;
ctos_proto
=
0
;
}
else
{
log
.
warn
(
"
bad ctos_message length
"
,
client
.
ip
);
break
;
}
}
...
...
@@ -975,12 +978,10 @@
}
}
});
server
.
on
(
'
data
'
,
function
(
data
)
{
var
b
,
buffer
,
cancel
,
datas
,
k
,
len
,
looplimit
,
stanzas
,
stoc_buffer
,
stoc_message_length
,
stoc_proto
,
struct
;
stoc_buffer
=
new
Buffer
(
0
);
server
.
on
(
'
data
'
,
function
(
stoc_buffer
)
{
var
b
,
buffer
,
cancel
,
datas
,
k
,
len
,
looplimit
,
stanzas
,
stoc_message_length
,
stoc_proto
,
struct
;
stoc_message_length
=
0
;
stoc_proto
=
0
;
stoc_buffer
=
Buffer
.
concat
([
stoc_buffer
,
data
],
stoc_buffer
.
length
+
data
.
length
);
datas
=
[];
looplimit
=
0
;
while
(
true
)
{
...
...
@@ -988,12 +989,16 @@
if
(
stoc_buffer
.
length
>=
2
)
{
stoc_message_length
=
stoc_buffer
.
readUInt16LE
(
0
);
}
else
{
if
(
stoc_buffer
.
length
!==
0
)
{
log
.
warn
(
"
bad stoc_buffer length
"
,
client
.
ip
);
}
break
;
}
}
else
if
(
stoc_proto
===
0
)
{
if
(
stoc_buffer
.
length
>=
3
)
{
stoc_proto
=
stoc_buffer
.
readUInt8
(
2
);
}
else
{
log
.
warn
(
"
bad stoc_proto length
"
,
client
.
ip
);
break
;
}
}
else
{
...
...
@@ -1024,6 +1029,7 @@
stoc_message_length
=
0
;
stoc_proto
=
0
;
}
else
{
log
.
warn
(
"
bad stoc_message length
"
,
client
.
ip
);
break
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment