fixed some things
This commit is contained in:
parent
3a46c4ae44
commit
cd3aae9c1e
@ -28,7 +28,9 @@ Master:
|
|||||||
- master:peek()
|
- master:peek()
|
||||||
- master:pop()
|
- master:pop()
|
||||||
|
|
||||||
Note: These examples assume that you have already connected the nodes to the node manager. Also you do not need to use the node manager, but sometimes broadcast does not work as expected and the master doesnot connect to the nodes. Using the node manager offers nice features like: removing nodes from the master when they have disconnected, and automatically telling the master when nodes have been added.
|
**Note On Queues:** When it comes to network queues, they only send 1 way. What I mean by that is that if the master sends a message to a node, its own queue will not get populated at all. The reason for this is because syncing between which popped from what network queue would make things really slow and would not perform so well. This means you have to code a bit differently. Use: master getFreeNode() to get the name of the node under the least amount of load. Then handle the sending of data to each node that way.
|
||||||
|
|
||||||
|
**Note:** These examples assume that you have already connected the nodes to the node manager. Also you do not need to use the node manager, but sometimes broadcast does not work as expected and the master doesnot connect to the nodes. Using the node manager offers nice features like: removing nodes from the master when they have disconnected, and automatically telling the master when nodes have been added.
|
||||||
|
|
||||||
**NodeManager.lua**
|
**NodeManager.lua**
|
||||||
```lua
|
```lua
|
||||||
|
|||||||
@ -130,7 +130,7 @@ function multi:nodeManager(port)
|
|||||||
end
|
end
|
||||||
server.timeouts[cid] = true
|
server.timeouts[cid] = true
|
||||||
server:send(cid,"ping")
|
server:send(cid,"ping")
|
||||||
end,3)
|
end,.1)
|
||||||
server.nodes[cid]=data:sub(2,-1)
|
server.nodes[cid]=data:sub(2,-1)
|
||||||
server.OnNodeAdded:Fire(server.nodes[cid])
|
server.OnNodeAdded:Fire(server.nodes[cid])
|
||||||
elseif cmd == "G" then
|
elseif cmd == "G" then
|
||||||
|
|||||||
2
node.lua
2
node.lua
@ -5,7 +5,7 @@ nGLOBAL = require("multi.integration.networkManager").init()
|
|||||||
node = multi:newNode{
|
node = multi:newNode{
|
||||||
crossTalk = false, -- default value, allows nodes to talk to eachother. WIP NOT READY YET!
|
crossTalk = false, -- default value, allows nodes to talk to eachother. WIP NOT READY YET!
|
||||||
allowRemoteRegistering = true, -- allows you to register functions from the master on the node, default is false
|
allowRemoteRegistering = true, -- allows you to register functions from the master on the node, default is false
|
||||||
name = "TESTNODE", -- default value
|
name = nil, --"TESTNODE", -- default value
|
||||||
noBroadCast = true, -- if using the node manager, set this to true to prevent the node from broadcasting
|
noBroadCast = true, -- if using the node manager, set this to true to prevent the node from broadcasting
|
||||||
managerDetails = {"localhost",12345}, -- connects to the node manager if one exists
|
managerDetails = {"localhost",12345}, -- connects to the node manager if one exists
|
||||||
}
|
}
|
||||||
|
|||||||
5
test.lua
5
test.lua
@ -15,11 +15,14 @@ master.OnNodeConnected(function(node)
|
|||||||
print("Lets Go!")
|
print("Lets Go!")
|
||||||
master:execute("RemoteTest",node,1,2,3)
|
master:execute("RemoteTest",node,1,2,3)
|
||||||
multi:newThread("waiter",function()
|
multi:newThread("waiter",function()
|
||||||
print("Hello!")
|
print("Hello!",node)
|
||||||
while true do
|
while true do
|
||||||
thread.sleep(2)
|
thread.sleep(2)
|
||||||
print("sending")
|
print("sending")
|
||||||
master:pushTo(node,"This is a test 2")
|
master:pushTo(node,"This is a test 2")
|
||||||
|
if master.connections["NODE_"..node]==nil then
|
||||||
|
thread.kill()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user