Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
ds-project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alexander Schulz
ds-project
Commits
f721cb03
Commit
f721cb03
authored
1 year ago
by
Alexander Schulz
Browse files
Options
Downloads
Patches
Plain Diff
added comments
parent
b671b554
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
server.py
+8
-0
8 additions, 0 deletions
server.py
with
8 additions
and
0 deletions
server.py
+
8
−
0
View file @
f721cb03
...
...
@@ -313,6 +313,7 @@ class Server(multiprocessing.Process):
# ascii value before A
return
64
# listen for servers if they want to join the DS
def
listen_for_servers
(
self
):
BROADCAST_PORT
=
49154
...
...
@@ -437,6 +438,7 @@ class Server(multiprocessing.Process):
client_cache_key
=
group
+
str
(
self
.
client_cache_key_offset
)
self
.
local_clients_cache
[
client_cache_key
]
=
client_addr
# find address of groupchat server to inform client
def
find_groupchat_server_addresse
(
self
,
group
):
# double check if group really exist
for
key
in
self
.
local_group_cache
:
...
...
@@ -490,7 +492,9 @@ class Server(multiprocessing.Process):
#new_server.send_reply_to_client()
return
self
.
server_port
# send updated group view/servers cache to all server
def
updateCacheList
(
self
):
PORT
=
5980
BROADCAST_ADDRESS
=
self
.
get_broadcast_address
()
...
...
@@ -513,6 +517,7 @@ class Server(multiprocessing.Process):
broadcast_socket
.
sendto
(
MSG
,
(
BROADCAST_ADDRESS
,
PORT
))
broadcast_socket
.
close
()
# listen for update of the groupview/server cache by MAIN server
def
listen_for_cache_update
(
self
):
BROADCAST_ADDRESS
=
self
.
get_broadcast_address
()
BROADCAST_PORT
=
5980
...
...
@@ -555,6 +560,7 @@ class Server(multiprocessing.Process):
except
socket
.
timeout
:
pass
#Timeout reached
# listen for client chat messages to distribute them to all group members afterwards
def
listen_for_client_messages
(
self
):
PORT
=
50001
...
...
@@ -580,6 +586,7 @@ class Server(multiprocessing.Process):
if
message
:
self
.
distribute_chat_message
(
message
,
addr
)
# determine the receiver list of the received client chat message
def
distribute_chat_message
(
self
,
message
,
addr
):
group
=
self
.
find_group_of_client
(
addr
)
...
...
@@ -594,6 +601,7 @@ class Server(multiprocessing.Process):
distribute_chat_thread
=
threading
.
Thread
(
target
=
self
.
send_chat_message_to_clients
(
message
,
receiver_list
))
distribute_chat_thread
.
start
()
# distribute the received client chat message to all members of the group
def
send_chat_message_to_clients
(
self
,
message
,
receiver_list
):
PORT
=
51000
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment