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
1 parent
83c4882
commit 9594d1f
Showing
15 changed files
with
202 additions
and
467 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,6 @@ | ||
return { | ||
default = { | ||
coverage = true, | ||
pattern = '.lua' | ||
} | ||
} |
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,5 @@ | ||
# Silly Mac files | ||
.DS_Store | ||
|
||
# Code coverage files | ||
luacov.* |
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 |
---|---|---|
@@ -1,2 +1,17 @@ | ||
# simulsim | ||
Another attempt at a multiplayer framework. | ||
|
||
## Tests | ||
simulsim uses [busted](https://olivinelabs.com/busted/) for running tests, [LuaCOv](https://keplerproject.github.io/luacov/) for code coverage, and [Luacov-console](https://github.com/spacewander/luacov-console) for code coverage visualization. | ||
|
||
To get started, install all of the dependencies above using [LuaRocks](https://luarocks.org/): | ||
luarocks install busted | ||
luarocks install luacov | ||
luarocks install luacov-console | ||
|
||
To run the unit tests: | ||
busted ./tests | ||
|
||
To get a code coverage report: | ||
luacov && luacov-console && luacov-console -s | ||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
src/singlePlayer/Connection.lua → src/fauxNetwork/Connection.lua
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
File renamed without changes.
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
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,45 @@ | ||
-- Load dependencies | ||
local TransportLayer = require 'src/fauxNetwork/TransportLayer' | ||
local Connection = require 'src/fauxNetwork/Connection' | ||
local Server = require 'src/fauxNetwork/Server' | ||
|
||
-- Creates a fake, in-memory network of clients and servers | ||
return function(params) | ||
local numClients = params and params.numClients or 1 | ||
local transportLayerParams = { | ||
latency = params and params.latency, | ||
latencyDeviation = params and params.latencyDeviation, | ||
packetLossChance = params and params.packetLossChance | ||
} | ||
|
||
-- Create the server | ||
local server = Server:new() | ||
|
||
-- Create the clients | ||
local clients = {} | ||
for i = 1, numClients do | ||
-- Create the transport layers | ||
local clientToServer = TransportLayer:new(transportLayerParams) | ||
local serverToClient = TransportLayer:new(transportLayerParams) | ||
|
||
-- Create the server connection | ||
local serverConn = Connection:new({ | ||
isClient = false, | ||
sendTransportLayer = serverToClient, | ||
receiveTransportLayer = clientToServer | ||
}) | ||
serverConn:onConnect(function() | ||
server:handleConnect(serverConn) | ||
end) | ||
|
||
-- Create the client connection | ||
table.insert(clients, Connection:new({ | ||
isClient = true, | ||
sendTransportLayer = clientToServer, | ||
receiveTransportLayer = serverToClient | ||
})) | ||
end | ||
|
||
-- Return them | ||
return server, clients | ||
end |
Oops, something went wrong.