Skip to content
Snippets Groups Projects
Commit 4dccb07b authored by Tumbul, Erwin's avatar Tumbul, Erwin
Browse files

Merge branch 'main' into feature/android_client

parents 59b89207 ab545db6
Branches main
No related tags found
No related merge requests found
netcode/
import grpc
from netcode.netcode_pb2_grpc import NotifierComStub
from netcode.netcode_pb2 import *
channel = grpc.insecure_channel('localhost:8080')
stub = NotifierComStub(channel)
def sendMessage(msg):
request = SendMessageRequest(msg)
response = stub.SendMessage(request)
if __name__ == "__main__":
sendMessage("test")
\ No newline at end of file
import grpc
from concurrent import futures
from netcode.netcode_pb2_grpc import *
from netcode.netcode_pb2 import *
class NotifierService(NotifierComServicer):
def SendMessage(self, request, context):
print(request.message)
return Nothing()
if __name__ == "__main__":
server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
add_NotifierComServicer_to_server(
NotifierService, server)
server.add_insecure_port('[::]:8080')
server.start()
server.wait_for_termination()
#!/bin/bash
##################################
# Author: Martin Wistauder
# Date: 05.10.2021
# Version: 1.0
##################################
set -e
usage='Usage: ./gen-python-netcode.sh {protobuf source dir} {output dir}
Example usage: ./gen-python-netcode.sh ./protobuf ./netcode'
# check params
[ -z $1 ] && echo -e "Error: First parameter missing.\n$usage" && exit 1 || proto_dir="$1"
[ -z $2 ] && echo -e "Error: Second parameter missing.\n$usage" && exit 1 || output_dir="$2"
# vars
proto_dir="$1"
output_dir="$2"
# generate the python netcode
mkdir -p "$output_dir"
python -m grpc_tools.protoc -I"$proto_dir" --python_out="$output_dir" --grpc_python_out="$output_dir" $(find "$proto_dir" -name "*.proto" -printf "%P ")
syntax = "proto3";
package netcode;
service NotifierCom {
rpc SendMessage (SendMessageRequest) returns (Nothing);
}
message SendMessageRequest {
string message = 1;
}
message Nothing {
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment