forked from killalau/BombermanOnline
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 8403d1e
Showing
281 changed files
with
91,223 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Auto detect text files and perform LF normalization | ||
* text=auto | ||
|
||
# Custom for Visual Studio | ||
*.cs diff=csharp | ||
*.sln merge=union | ||
*.csproj merge=union | ||
*.vbproj merge=union | ||
*.fsproj merge=union | ||
*.dbproj merge=union | ||
|
||
# Standard to msysgit | ||
*.doc diff=astextplain | ||
*.DOC diff=astextplain | ||
*.docx diff=astextplain | ||
*.DOCX diff=astextplain | ||
*.dot diff=astextplain | ||
*.DOT diff=astextplain | ||
*.pdf diff=astextplain | ||
*.PDF diff=astextplain | ||
*.rtf diff=astextplain | ||
*.RTF diff=astextplain |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
################# | ||
## Eclipse | ||
################# | ||
|
||
*.pydevproject | ||
.project | ||
.metadata | ||
bin/ | ||
tmp/ | ||
*.tmp | ||
*.bak | ||
*.swp | ||
*~.nib | ||
local.properties | ||
.classpath | ||
.settings/ | ||
.loadpath | ||
|
||
# External tool builders | ||
.externalToolBuilders/ | ||
|
||
# Locally stored "Eclipse launch configurations" | ||
*.launch | ||
|
||
# CDT-specific | ||
.cproject | ||
|
||
# PDT-specific | ||
.buildpath | ||
|
||
|
||
################# | ||
## Visual Studio | ||
################# | ||
|
||
## Ignore Visual Studio temporary files, build results, and | ||
## files generated by popular Visual Studio add-ons. | ||
|
||
# User-specific files | ||
*.suo | ||
*.user | ||
*.sln.docstates | ||
|
||
# Build results | ||
[Dd]ebug/ | ||
[Rr]elease/ | ||
*_i.c | ||
*_p.c | ||
*.ilk | ||
*.meta | ||
*.obj | ||
*.pch | ||
*.pdb | ||
*.pgc | ||
*.pgd | ||
*.rsp | ||
*.sbr | ||
*.tlb | ||
*.tli | ||
*.tlh | ||
*.tmp | ||
*.vspscc | ||
.builds | ||
*.dotCover | ||
|
||
## TODO: If you have NuGet Package Restore enabled, uncomment this | ||
#packages/ | ||
|
||
# Visual C++ cache files | ||
ipch/ | ||
*.aps | ||
*.ncb | ||
*.opensdf | ||
*.sdf | ||
|
||
# Visual Studio profiler | ||
*.psess | ||
*.vsp | ||
|
||
# ReSharper is a .NET coding add-in | ||
_ReSharper* | ||
|
||
# Installshield output folder | ||
[Ee]xpress | ||
|
||
# DocProject is a documentation generator add-in | ||
DocProject/buildhelp/ | ||
DocProject/Help/*.HxT | ||
DocProject/Help/*.HxC | ||
DocProject/Help/*.hhc | ||
DocProject/Help/*.hhk | ||
DocProject/Help/*.hhp | ||
DocProject/Help/Html2 | ||
DocProject/Help/html | ||
|
||
# Click-Once directory | ||
publish | ||
|
||
# Others | ||
[Bb]in | ||
[Oo]bj | ||
sql | ||
TestResults | ||
*.Cache | ||
ClientBin | ||
stylecop.* | ||
~$* | ||
*.dbmdl | ||
Generated_Code #added for RIA/Silverlight projects | ||
|
||
# Backup & report files from converting an old project file to a newer | ||
# Visual Studio version. Backup files are not needed, because we have git ;-) | ||
_UpgradeReport_Files/ | ||
Backup*/ | ||
UpgradeLog*.XML | ||
|
||
|
||
|
||
############ | ||
## Windows | ||
############ | ||
|
||
# Windows image file caches | ||
Thumbs.db | ||
|
||
# Folder config file | ||
Desktop.ini | ||
|
||
|
||
############# | ||
## Python | ||
############# | ||
|
||
*.py[co] | ||
|
||
# Packages | ||
*.egg | ||
*.egg-info | ||
dist | ||
build | ||
eggs | ||
parts | ||
bin | ||
var | ||
sdist | ||
develop-eggs | ||
.installed.cfg | ||
|
||
# Installer logs | ||
pip-log.txt | ||
|
||
# Unit test / coverage reports | ||
.coverage | ||
.tox | ||
|
||
#Translations | ||
*.mo | ||
|
||
#Mr Developer | ||
.mr.developer.cfg | ||
|
||
# Mac crap | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
AuthName "Forbidden" | ||
AuthType Digest | ||
require user admin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
=====Version 6=============== | ||
Add back something I missed in combining project | ||
- gameServer.js | ||
about the room creation | ||
|
||
=====Version 5=============== | ||
Combine with Mond stuff, mainly the Lobby | ||
|
||
Changes: | ||
- move all HTML page in to the folder "web/" | ||
modify readHTML() in wsRequestHandlers.js | ||
- fixed bug: | ||
joinRoom() in wsRequestHandlers.js | ||
bufRm= gClient.room+1; | ||
=> bufRm= gClient.room; | ||
- fixed bug: | ||
gameRoom.removeClient() | ||
re-implement | ||
- change from atrribute to function: | ||
gameRoom.ping() | ||
|
||
=====Version 4=============== | ||
Changes: | ||
- modify: | ||
gameClient.boardcastData() | ||
the boardcast data would include the event trigged username | ||
- modify: | ||
script/webSocket.js | ||
1) ping calculation checking | ||
2) function for create default callback handlers | ||
- modify: | ||
chatroom.html | ||
var handlers = {}; | ||
=> var handlers = webSocket.createHandlers(); | ||
|
||
=====Version 3=============== | ||
PS. "main.js" is the entry point of the whole server program. | ||
|
||
PS. "server.js", "router.js", "requestHandlers.js" is a set of program doing something like Apache | ||
|
||
PS. "wsServer.js", "wsRouter.js", "wsRequestHandlers.js" is a set of program handle WebSocket, with a similar structure. | ||
|
||
PS. "gameServer.js", "gameRoom.js", "gameClient.js" define 3 Class of object, which we would use in WebSocket programming. | ||
|
||
PS. All client side Javascript is (must) placed in "scripts/" | ||
|
||
PS. See "chatroom.html", it demo many thing. (Mainly related resources: 'scripts/webSocket.js', 'scripts/chatroom.js', 'main.js', 'wsRequestHandlers.js') | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* Create a client object | ||
* | ||
* connection: websocket connection of client | ||
* server: gameServer object | ||
* room: room number in 'gameServer.roomList[]' | ||
*/ | ||
function create(connection, server, room){ | ||
if(!connection || isNaN(room)) | ||
return null; | ||
|
||
// Create client object | ||
var client = { | ||
connection : connection, // websocket connection | ||
room : room, // room number | ||
username: false, // username | ||
ping: false, // ping value | ||
seat: -1, // cleint seat number | ||
isHost: false, | ||
requestTimestamp: false, // prevous request timestamp, for client side ping calculation | ||
disconnectFunction: false, // timeout function when connection break, or change page | ||
sendData : function(type, data){ // send data to client | ||
console.log("[Client] Send data: " + type + " to user: " + client.username); | ||
|
||
var stime = new Date(); | ||
var msg = { | ||
username: client.username, | ||
requestTimestamp : client.requestTimestamp, | ||
serverTimestamp : stime, | ||
type: type, | ||
data: data | ||
}; | ||
if(client.connection) | ||
client.connection.sendUTF(JSON.stringify(msg)); | ||
}, | ||
boardcastData : function(type, data){ // boardcast data to the room which the client is stay in | ||
console.log("[Client] Boardcast data: " + type + " from user: " + client.username + " to room :" + server.roomList[client.room].name); | ||
|
||
var stime = new Date(); | ||
var msg = { | ||
username: client.username, | ||
serverTimestamp : stime, | ||
type: type, | ||
data: data | ||
}; | ||
|
||
for(var i = 0, c; c = server.roomList[client.room].clientList[i]; i++){ | ||
if(c.connection) | ||
c.connection.sendUTF(JSON.stringify(msg)); | ||
} | ||
}, | ||
reconnectCopy : function(oldClient){ // copy value from another client object, used in reconnection handling | ||
client.room = oldClient.room; | ||
client.ping = oldClient.ping; | ||
client.seat = oldClient.seat; | ||
client.isHost = oldClient.isHost; | ||
} | ||
} | ||
|
||
// Add client to room | ||
server.roomList[client.room].addClient(server, client); | ||
return client; | ||
} | ||
|
||
exports.create = create; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* Create room object | ||
* | ||
* isLobby: (bool) | ||
* rid: room ID | ||
* name: room name | ||
* np(): number of players | ||
* ping(): average player ping (default: 0) | ||
*/ | ||
function create(isLobby, name){ | ||
isLobby = isLobby ? true : false; | ||
name = name ? name : "Room"; | ||
|
||
var room = { | ||
isLobby : isLobby, // lobby flag | ||
rid: -1, // room ID | ||
name : name, // room name | ||
clientList : [], // client list in that room | ||
seatList: [false, false, false, false], | ||
host: false, | ||
np: function(){ return room.clientList.length; }, | ||
ping: function(){ | ||
var n = 0, sum = 0; | ||
for(var i = 0, c; c = room.clientList[i]; i++){ | ||
if(c.ping && c.ping.avgping > 0){ | ||
n++; | ||
sum += c.ping.avgping; | ||
} | ||
} | ||
if(n == 0) return n; | ||
return Math.round(sum/n); | ||
}, | ||
addClient : function(server, client){ // add a client to the room | ||
|
||
|
||
// check exceed the room capacity | ||
var valid = room.isLobby || room.clientList.length < 4 ? true : false; | ||
if(valid){ | ||
// find the room number | ||
for(var i = 0, r; r = server.roomList[i]; i++){ | ||
if(r === room){ | ||
client.room = i; | ||
} | ||
} | ||
// add to room | ||
room.clientList.push(client); | ||
} | ||
|
||
|
||
|
||
return valid; | ||
}, | ||
removeClient : function(gServer, gClient){ | ||
for(var i = 0, c; c = room.clientList[i]; i++){ | ||
if(gClient === room.clientList[i]){ | ||
room.clientList.splice(i,1); | ||
break; | ||
} | ||
} | ||
}, | ||
boardcastData : function(eventType, data, srcName){ | ||
var stime = new Date(); | ||
var msg = { | ||
username: srcName, | ||
serverTimestamp : stime, | ||
type: eventType, | ||
data: data | ||
}; | ||
for(var i = 0, c; c = room.clientList[i]; i++){ | ||
if(c.connection) | ||
c.connection.sendUTF(JSON.stringify(msg)); | ||
console.log("[gameRoom.boardcastData] src="+srcName+" target="+c.username); | ||
console.log("[gameRoom.boardcastData] data="+data); | ||
} | ||
} | ||
|
||
|
||
|
||
}; | ||
|
||
return room; | ||
} | ||
|
||
exports.create = create; |
Oops, something went wrong.