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
4ce74bb8
Commit
4ce74bb8
authored
May 25, 2016
by
mercury233
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix buffer
parent
11a6c414
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
19 deletions
+20
-19
ygopro-server.coffee
ygopro-server.coffee
+11
-10
ygopro-server.js
ygopro-server.js
+9
-9
No files found.
ygopro-server.coffee
View file @
4ce74bb8
...
@@ -82,6 +82,7 @@ setInterval ()->
...
@@ -82,6 +82,7 @@ setInterval ()->
Graveyard
[
i
][
j
]
=
null
Graveyard
[
i
][
j
]
=
null
Graveyard
[
i
]
=
null
Graveyard
[
i
]
=
null
Graveyard
=
[]
Graveyard
=
[]
#global.gc()
return
return
,
3000
,
3000
...
@@ -156,16 +157,16 @@ net.createServer (client) ->
...
@@ -156,16 +157,16 @@ net.createServer (client) ->
#需要重构
#需要重构
#客户端到服务端(ctos)协议分析
#客户端到服务端(ctos)协议分析
ctos_buffer
=
new
Buffer
(
0
)
ctos_message_length
=
0
ctos_proto
=
0
client
.
pre_establish_buffers
=
new
Array
()
client
.
pre_establish_buffers
=
new
Array
()
client
.
on
'data'
,
(
data
)
->
client
.
on
'data'
,
(
data
)
->
if
client
.
is_post_watcher
if
client
.
is_post_watcher
client
.
room
.
watcher
.
write
data
client
.
room
.
watcher
.
write
data
else
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
)
#buffer的错误使用方式,好孩子不要学
ctos_buffer
=
Buffer
.
concat
([
ctos_buffer
,
data
],
ctos_buffer
.
length
+
data
.
length
)
#buffer的错误使用方式,好孩子不要学
datas
=
[]
datas
=
[]
...
@@ -185,7 +186,7 @@ net.createServer (client) ->
...
@@ -185,7 +186,7 @@ net.createServer (client) ->
break
break
else
else
if
ctos_buffer
.
length
>=
2
+
ctos_message_length
if
ctos_buffer
.
length
>=
2
+
ctos_message_length
#console.log "CTOS", ygopro.constants.CTOS[ctos_proto]
#console.log "CTOS", ygopro.constants.CTOS[ctos_proto]
cancel
=
false
cancel
=
false
if
ygopro
.
ctos_follows
[
ctos_proto
]
if
ygopro
.
ctos_follows
[
ctos_proto
]
b
=
ctos_buffer
.
slice
(
3
,
ctos_message_length
-
1
+
3
)
b
=
ctos_buffer
.
slice
(
3
,
ctos_message_length
-
1
+
3
)
...
@@ -219,11 +220,10 @@ net.createServer (client) ->
...
@@ -219,11 +220,10 @@ net.createServer (client) ->
return
return
#服务端到客户端(stoc)
#服务端到客户端(stoc)
stoc_buffer
=
new
Buffer
(
0
)
stoc_message_length
=
0
stoc_proto
=
0
server
.
on
'data'
,
(
data
)
->
server
.
on
'data'
,
(
data
)
->
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
#unless ygopro.stoc_follows[stoc_proto] and ygopro.stoc_follows[stoc_proto].synchronous
...
@@ -244,7 +244,7 @@ net.createServer (client) ->
...
@@ -244,7 +244,7 @@ net.createServer (client) ->
break
break
else
else
if
stoc_buffer
.
length
>=
2
+
stoc_message_length
if
stoc_buffer
.
length
>=
2
+
stoc_message_length
#console.log "STOC", ygopro.constants.STOC[stoc_proto]
#console.log "STOC", ygopro.constants.STOC[stoc_proto]
stanzas
=
stoc_proto
stanzas
=
stoc_proto
if
ygopro
.
stoc_follows
[
stoc_proto
]
if
ygopro
.
stoc_follows
[
stoc_proto
]
b
=
stoc_buffer
.
slice
(
3
,
stoc_message_length
-
1
+
3
)
b
=
stoc_buffer
.
slice
(
3
,
stoc_message_length
-
1
+
3
)
...
@@ -509,6 +509,7 @@ ygopro.stoc_follow 'JOIN_GAME', false, (buffer, info, client, server)->
...
@@ -509,6 +509,7 @@ ygopro.stoc_follow 'JOIN_GAME', false, (buffer, info, client, server)->
ygopro
.
stoc_send_chat
(
client
,
settings
.
modules
.
welcome
,
ygopro
.
constants
.
COLORS
.
GREEN
)
ygopro
.
stoc_send_chat
(
client
,
settings
.
modules
.
welcome
,
ygopro
.
constants
.
COLORS
.
GREEN
)
if
client
.
room
.
welcome
if
client
.
room
.
welcome
ygopro
.
stoc_send_chat
(
client
,
client
.
room
.
welcome
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
)
ygopro
.
stoc_send_chat
(
client
,
client
.
room
.
welcome
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
)
#log.info (client.room)
if
!
client
.
room
.
recorder
if
!
client
.
room
.
recorder
client
.
room
.
recorder
=
recorder
=
net
.
connect
client
.
room
.
port
,
->
client
.
room
.
recorder
=
recorder
=
net
.
connect
client
.
room
.
port
,
->
...
...
ygopro-server.js
View file @
4ce74bb8
...
@@ -138,7 +138,7 @@
...
@@ -138,7 +138,7 @@
},
3000
);
},
3000
);
net
.
createServer
(
function
(
client
)
{
net
.
createServer
(
function
(
client
)
{
var
ctos_buffer
,
ctos_message_length
,
ctos_proto
,
server
,
stoc_buffer
,
stoc_message_length
,
stoc_proto
;
var
server
;
server
=
new
net
.
Socket
();
server
=
new
net
.
Socket
();
client
.
server
=
server
;
client
.
server
=
server
;
client
.
setTimeout
(
300000
);
client
.
setTimeout
(
300000
);
...
@@ -207,15 +207,15 @@
...
@@ -207,15 +207,15 @@
});
});
};
};
}
}
ctos_buffer
=
new
Buffer
(
0
);
ctos_message_length
=
0
;
ctos_proto
=
0
;
client
.
pre_establish_buffers
=
new
Array
();
client
.
pre_establish_buffers
=
new
Array
();
client
.
on
(
'
data
'
,
function
(
data
)
{
client
.
on
(
'
data
'
,
function
(
data
)
{
var
b
,
buffer
,
cancel
,
datas
,
k
,
l
,
len
,
len1
,
looplimit
,
struct
;
var
b
,
buffer
,
cancel
,
ctos_buffer
,
ctos_message_length
,
ctos_proto
,
datas
,
k
,
l
,
len
,
len1
,
looplimit
,
struct
;
if
(
client
.
is_post_watcher
)
{
if
(
client
.
is_post_watcher
)
{
client
.
room
.
watcher
.
write
(
data
);
client
.
room
.
watcher
.
write
(
data
);
}
else
{
}
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
);
ctos_buffer
=
Buffer
.
concat
([
ctos_buffer
,
data
],
ctos_buffer
.
length
+
data
.
length
);
datas
=
[];
datas
=
[];
looplimit
=
0
;
looplimit
=
0
;
...
@@ -278,11 +278,11 @@
...
@@ -278,11 +278,11 @@
}
}
}
}
});
});
stoc_buffer
=
new
Buffer
(
0
);
stoc_message_length
=
0
;
stoc_proto
=
0
;
server
.
on
(
'
data
'
,
function
(
data
)
{
server
.
on
(
'
data
'
,
function
(
data
)
{
var
b
,
looplimit
,
stanzas
,
struct
;
var
b
,
looplimit
,
stanzas
,
stoc_buffer
,
stoc_message_length
,
stoc_proto
,
struct
;
stoc_buffer
=
new
Buffer
(
0
);
stoc_message_length
=
0
;
stoc_proto
=
0
;
stoc_buffer
=
Buffer
.
concat
([
stoc_buffer
,
data
],
stoc_buffer
.
length
+
data
.
length
);
stoc_buffer
=
Buffer
.
concat
([
stoc_buffer
,
data
],
stoc_buffer
.
length
+
data
.
length
);
client
.
write
(
data
);
client
.
write
(
data
);
looplimit
=
0
;
looplimit
=
0
;
...
...
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