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
eb0a701c
Commit
eb0a701c
authored
Jan 21, 2017
by
mercury233
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
观战列表
parent
7b9afc11
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
57 additions
and
27 deletions
+57
-27
roomlist.coffee
roomlist.coffee
+22
-10
roomlist.js
roomlist.js
+29
-11
ygopro-server.coffee
ygopro-server.coffee
+3
-3
ygopro-server.js
ygopro-server.js
+3
-3
No files found.
roomlist.coffee
View file @
eb0a701c
WebSocketServer
=
require
(
'ws'
).
Server
url
=
require
(
'url'
)
settings
=
global
.
settings
server
=
null
...
...
@@ -8,32 +9,41 @@ room_data = (room)->
title
:
room
.
title
,
user
:
{
username
:
room
.
username
}
users
:
({
username
:
client
.
name
,
position
:
client
.
pos
}
for
client
in
room
.
players
),
options
:
room
.
hostinfo
options
:
room
.
hostinfo
,
arena
:
settings
.
modules
.
arena_mode
.
enabled
&&
room
.
arena
&&
settings
.
modules
.
arena_mode
.
mode
init
=
(
http_server
,
ROOM_all
)
->
server
=
new
WebSocketServer
server
:
http_server
server
.
on
'connection'
,
(
connection
)
->
connection
.
filter
=
url
.
parse
(
connection
.
upgradeReq
.
url
,
true
).
query
.
filter
||
'waiting'
connection
.
send
JSON
.
stringify
event
:
'init'
data
:
room_data
(
room
)
for
room
in
ROOM_all
when
room
and
room
.
established
and
!
room
.
private
and
!
room
.
started
data
:
room_data
(
room
)
for
room
in
ROOM_all
when
room
and
room
.
established
and
!
room
.
private
and
(
room
.
started
==
(
connection
.
filter
==
'started'
))
create
=
(
room
)
->
broadcast
(
'create'
,
room_data
(
room
))
broadcast
(
'create'
,
room_data
(
room
)
,
'waiting'
)
update
=
(
room
)
->
broadcast
(
'update'
,
room_data
(
room
))
broadcast
(
'update'
,
room_data
(
room
),
'waiting'
)
start
=
(
room
)
->
broadcast
(
'delete'
,
room_data
(
room
),
'waiting'
)
broadcast
(
'create'
,
room_data
(
room
),
'started'
)
_delete
=
(
room_id
)
->
broadcast
(
'delete'
,
room_id
)
_delete
=
(
room
)
->
if
(
room
.
started
)
broadcast
(
'delete'
,
room
.
name
,
'started'
)
else
broadcast
(
'delete'
,
room
.
name
,
'waiting'
)
broadcast
=
(
event
,
data
)
->
broadcast
=
(
event
,
data
,
filter
)
->
return
if
!
server
message
=
JSON
.
stringify
event
:
event
data
:
data
for
connection
in
server
.
clients
for
connection
in
server
.
clients
when
connection
.
filter
==
filter
try
connection
.
send
message
...
...
@@ -41,4 +51,6 @@ module.exports =
init
:
init
create
:
create
update
:
update
delete
:
_delete
\ No newline at end of file
start
:
start
delete
:
_delete
roomlist.js
View file @
eb0a701c
// Generated by CoffeeScript 1.12.2
(
function
()
{
var
WebSocketServer
,
_delete
,
broadcast
,
create
,
init
,
room_data
,
server
,
update
;
var
WebSocketServer
,
_delete
,
broadcast
,
create
,
init
,
room_data
,
server
,
settings
,
start
,
update
,
url
;
WebSocketServer
=
require
(
'
ws
'
).
Server
;
url
=
require
(
'
url
'
);
settings
=
global
.
settings
;
server
=
null
;
room_data
=
function
(
room
)
{
...
...
@@ -27,7 +31,8 @@
}
return
results
;
})(),
options
:
room
.
hostinfo
options
:
room
.
hostinfo
,
arena
:
settings
.
modules
.
arena_mode
.
enabled
&&
room
.
arena
&&
settings
.
modules
.
arena_mode
.
mode
};
};
...
...
@@ -37,6 +42,7 @@
});
return
server
.
on
(
'
connection
'
,
function
(
connection
)
{
var
room
;
connection
.
filter
=
url
.
parse
(
connection
.
upgradeReq
.
url
,
true
).
query
.
filter
||
'
waiting
'
;
return
connection
.
send
(
JSON
.
stringify
({
event
:
'
init
'
,
data
:
(
function
()
{
...
...
@@ -44,7 +50,7 @@
results
=
[];
for
(
i
=
0
,
len
=
ROOM_all
.
length
;
i
<
len
;
i
++
)
{
room
=
ROOM_all
[
i
];
if
(
room
&&
room
.
established
&&
!
room
[
"
private
"
]
&&
!
room
.
started
)
{
if
(
room
&&
room
.
established
&&
!
room
[
"
private
"
]
&&
(
room
.
started
===
(
connection
.
filter
===
'
started
'
))
)
{
results
.
push
(
room_data
(
room
));
}
}
...
...
@@ -55,18 +61,27 @@
};
create
=
function
(
room
)
{
return
broadcast
(
'
create
'
,
room_data
(
room
));
return
broadcast
(
'
create
'
,
room_data
(
room
)
,
'
waiting
'
);
};
update
=
function
(
room
)
{
return
broadcast
(
'
update
'
,
room_data
(
room
));
return
broadcast
(
'
update
'
,
room_data
(
room
)
,
'
waiting
'
);
};
_delete
=
function
(
room_id
)
{
return
broadcast
(
'
delete
'
,
room_id
);
start
=
function
(
room
)
{
broadcast
(
'
delete
'
,
room_data
(
room
),
'
waiting
'
);
return
broadcast
(
'
create
'
,
room_data
(
room
),
'
started
'
);
};
_delete
=
function
(
room
)
{
if
(
room
.
started
)
{
return
broadcast
(
'
delete
'
,
room
.
name
,
'
started
'
);
}
else
{
return
broadcast
(
'
delete
'
,
room
.
name
,
'
waiting
'
);
}
};
broadcast
=
function
(
event
,
data
)
{
broadcast
=
function
(
event
,
data
,
filter
)
{
var
connection
,
i
,
len
,
message
,
ref
,
results
;
if
(
!
server
)
{
return
;
...
...
@@ -79,9 +94,11 @@
results
=
[];
for
(
i
=
0
,
len
=
ref
.
length
;
i
<
len
;
i
++
)
{
connection
=
ref
[
i
];
try
{
results
.
push
(
connection
.
send
(
message
));
}
catch
(
error
)
{}
if
(
connection
.
filter
===
filter
)
{
try
{
results
.
push
(
connection
.
send
(
message
));
}
catch
(
error
)
{}
}
}
return
results
;
};
...
...
@@ -90,6 +107,7 @@
init
:
init
,
create
:
create
,
update
:
update
,
start
:
start
,
"
delete
"
:
_delete
};
...
...
ygopro-server.coffee
View file @
eb0a701c
...
...
@@ -503,7 +503,7 @@ class Room
index
=
_
.
indexOf
(
ROOM_all
,
this
)
ROOM_all
[
index
]
=
null
unless
index
==
-
1
#ROOM_all.splice(index, 1) unless index == -1
roomlist
.
delete
@
name
if
!
@
private
and
!
@
started
and
@
established
and
settings
.
modules
.
http
.
websocket_roomlist
roomlist
.
delete
this
if
!
@
private
and
@
established
and
settings
.
modules
.
http
.
websocket_roomlist
return
get_playing_player
:
->
...
...
@@ -1352,7 +1352,7 @@ ygopro.stoc_follow 'DUEL_START', false, (buffer, info, client, server)->
unless
room
.
started
#first start
room
.
started
=
true
room
.
start_time
=
moment
().
format
()
roomlist
.
delete
room
.
name
if
settings
.
modules
.
http
.
websocket_roomlist
and
not
room
.
private
roomlist
.
start
room
if
settings
.
modules
.
http
.
websocket_roomlist
and
not
room
.
private
#room.duels = []
room
.
dueling_players
=
[]
for
player
in
room
.
players
when
player
.
pos
!=
7
...
...
@@ -1797,4 +1797,4 @@ if settings.modules.http
key
:
fs
.
readFileSync
(
settings
.
modules
.
http
.
ssl
.
key
)
https_server
=
https
.
createServer
(
options
,
requestListener
)
roomlist
.
init
https_server
,
ROOM_all
https_server
.
listen
settings
.
modules
.
http
.
ssl
.
port
\ No newline at end of file
https_server
.
listen
settings
.
modules
.
http
.
ssl
.
port
ygopro-server.js
View file @
eb0a701c
...
...
@@ -676,8 +676,8 @@
if
(
index
!==
-
1
)
{
ROOM_all
[
index
]
=
null
;
}
if
(
!
this
[
"
private
"
]
&&
!
this
.
started
&&
this
.
established
&&
settings
.
modules
.
http
.
websocket_roomlist
)
{
roomlist
[
"
delete
"
](
this
.
name
);
if
(
!
this
[
"
private
"
]
&&
this
.
established
&&
settings
.
modules
.
http
.
websocket_roomlist
)
{
roomlist
[
"
delete
"
](
this
);
}
};
...
...
@@ -1654,7 +1654,7 @@
room
.
started
=
true
;
room
.
start_time
=
moment
().
format
();
if
(
settings
.
modules
.
http
.
websocket_roomlist
&&
!
room
[
"
private
"
])
{
roomlist
[
"
delete
"
](
room
.
name
);
roomlist
.
start
(
room
);
}
room
.
dueling_players
=
[];
ref
=
room
.
players
;
...
...
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