Merge branch 'master' of https://bitbucket.org/mreenen/endopdracht-groep-5
This commit is contained in:
commit
fd8901c596
35
python server/EMS20_Groep-5_UDP-Server.pyproj
Normal file
35
python server/EMS20_Groep-5_UDP-Server.pyproj
Normal file
@ -0,0 +1,35 @@
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>c00d3363-b79d-4e9e-be8e-6206aff6b78d</ProjectGuid>
|
||||
<ProjectHome>.</ProjectHome>
|
||||
<StartupFile>EMS20_Groep_5_UDP_Server.py</StartupFile>
|
||||
<SearchPath>
|
||||
</SearchPath>
|
||||
<WorkingDirectory>.</WorkingDirectory>
|
||||
<OutputPath>.</OutputPath>
|
||||
<Name>EMS20_Groep-5_UDP-Server</Name>
|
||||
<RootNamespace>EMS20_Groep-5_UDP-Server</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="EMS20_Groep_5_UDP_Server.py" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Python Tools\Microsoft.PythonTools.targets" />
|
||||
<!-- Uncomment the CoreCompile target to enable the Build command in
|
||||
Visual Studio and specify your pre- and post-build commands in
|
||||
the BeforeBuild and AfterBuild targets below. -->
|
||||
<!--<Target Name="CoreCompile" />-->
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
</Project>
|
||||
37
python server/EMS20_Groep_5_UDP_Server.py
Normal file
37
python server/EMS20_Groep_5_UDP_Server.py
Normal file
@ -0,0 +1,37 @@
|
||||
import socket
|
||||
from time import sleep
|
||||
|
||||
UDP_IP = '0.0.0.0' # IP van de gebruiker
|
||||
UDP_PORT = 0 # Port van de UDP server
|
||||
|
||||
cooleSokken = socket.socket(socket.AF_INET, # Internet
|
||||
socket.SOCK_DGRAM) # UDP
|
||||
cooleSokken.bind((UDP_IP, UDP_PORT))
|
||||
|
||||
def recvUDP():
|
||||
data = cooleSokken.recv(1024)
|
||||
return str(data)
|
||||
|
||||
while True:
|
||||
data = recvUDP()
|
||||
if data == 'Handdruk aangeboden':
|
||||
wachtEventjes = 0
|
||||
while wachtEventjes != 10:
|
||||
wachtEventjes += 0.1
|
||||
data = recvUDP()
|
||||
if (data != 0) & (data != 'Handdruk aangeboden'):
|
||||
print(data, " heeft je hand geschud :D")
|
||||
break
|
||||
sleep(0.1)
|
||||
|
||||
elif data != 0:
|
||||
wachtEventjes = 0
|
||||
aanbieder = data
|
||||
print(data + " bied je een handdruk aan")
|
||||
while wachtEventjes != 10:
|
||||
wachtEventjes += 0.1
|
||||
data = recvUDP()
|
||||
if data == 'Handdruk aangeboden':
|
||||
print("Je hebt de hand geaccepteerd van ", aanbieder, " :D")
|
||||
break
|
||||
sleep(0.1)
|
||||
Loading…
x
Reference in New Issue
Block a user