-
Notifications
You must be signed in to change notification settings - Fork 380
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support channels? #50
Comments
Hello, def read_http_headers(self):
headers = {}
# first line should be HTTP GET
http_get = self.rfile.readline().decode().strip()
# Next three lines will get your end_point
global with_end_point
if re.search('\/([A-Za-z0-9]+)', http_get).group(1):
with_end_point = re.search('\/([A-Za-z0-9]+)', http_get).group(1)
assert http_get.upper().startswith('GET')
# remaining should be headers
while True:
header = self.rfile.readline().decode().strip()
if not header:
break
head, value = header.split(':', 1)
headers[head.lower().strip()] = value.strip()
return headers Change in WebsocketServer class: def _new_client_(self, handler):
self.id_counter += 1
# This if-else block will check if you have provided an end_point and if you have, it assigns that
# endpoint as the 'Id' of the socket connection, otherwise it will assign a number as 'Id'
if with_end_point:
client = {
'id': with_end_point,
'handler': handler,
'address': handler.client_address
}
else:
client = {
'id': self.id_counter,
'handler': handler,
'address': handler.client_address
}
self.clients.append(client)
self.new_client(client, self) And finally in your main script, use sever.send_message method to send the message to specific id or end point. |
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello,
I testing this proyect, I was wondering if:
can I define canals to transmite a message?
Is this possble?
e.g.:
"ws://localhost:port/Channel1"
"ws://localhost:port/Channel2"
So, with this configuration I could connect as a Client with this topic, for example to the "Channel1", and transmit news, and then I could to connect to the topic "Channel2", and transmit errors.
Thanks for all!
The text was updated successfully, but these errors were encountered: