Add files via upload
This commit is contained in:
parent
0e92cb4822
commit
c47f1892f8
@ -21,7 +21,14 @@ function net.chatting:init() -- calling this initilizes the library and binds it
|
||||
msg=msg
|
||||
}
|
||||
self.OnChatRecieved:Fire(struct) -- trigger the chat event
|
||||
self:sendAll("!chatting! "..struct.user.." '"..struct.msg.."'")
|
||||
for i,v in pairs(self.ips) do
|
||||
if ip==v then
|
||||
print("Self: "..struct.user)
|
||||
self:send(v,"!chatting! 1 "..struct.user.." '"..struct.msg.."'")
|
||||
else
|
||||
self:send(v,"!chatting! 0 "..struct.user.." '"..struct.msg.."'")
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
s.rooms={}
|
||||
@ -34,10 +41,11 @@ function net.chatting:init() -- calling this initilizes the library and binds it
|
||||
net.OnClientCreated:connect(function(c)
|
||||
c.OnDataRecieved:connect(function(self,data) -- when the client recieves data this method is triggered
|
||||
--First Lets make sure we are getting chatting data
|
||||
local user,msg = data:match("!chatting! (%S-) '(.+)'")
|
||||
local isself, user,msg = data:match("!chatting! (%d) (%S-) '(.+)'")
|
||||
if user and msg then
|
||||
--This is the client so our job here is done
|
||||
self.OnChatRecieved:Fire(user,msg) -- trigger the chat event
|
||||
print(isself)
|
||||
self.OnChatRecieved:Fire(user,msg,({["1"]=true, ["0"]=false})[isself]) -- trigger the chat event
|
||||
end
|
||||
end)
|
||||
function c:sendChat(user,msg)
|
||||
|
||||
@ -3,4 +3,7 @@ require("Libs/MultiManager") -- allows for multitasking
|
||||
require("net") -- Loads the networking library
|
||||
require("net.chatting") -- loads the networking chatting module
|
||||
server=net:newTCPServer(12345) -- starts a server with the port 12345 on local host
|
||||
server.OnChatRecieved(function(struct) -- where we handle users and messages
|
||||
print(struct.user..": "..struct.msg)
|
||||
end)
|
||||
multi:mainloop() -- starts the mainloop to keep the server going
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user