GL - merge
This commit is contained in:
commit
09693c7f35
|
@ -31,12 +31,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Game", "Game", "{20720CA7-7
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GameLogic", "Game\GameLogic\GameLogic.vcxproj", "{B1195BB9-B3A5-47F0-906C-8DEA384D1520}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GameLogic", "Game\GameLogic\GameLogic.vcxproj", "{B1195BB9-B3A5-47F0-906C-8DEA384D1520}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DanBiasServer", "Game\DanBiasServer\DanBiasServer.vcxproj", "{52380DAA-0F4A-4D97-8E57-98DF39319CAF}"
|
|
||||||
EndProject
|
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DanBiasLauncher", "Game\DanBiasLauncher\DanBiasLauncher.vcxproj", "{8690FDDF-C5B7-4C42-A337-BD5243F29B85}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DanBiasLauncher", "Game\DanBiasLauncher\DanBiasLauncher.vcxproj", "{8690FDDF-C5B7-4C42-A337-BD5243F29B85}"
|
||||||
ProjectSection(ProjectDependencies) = postProject
|
|
||||||
{52380DAA-0F4A-4D97-8E57-98DF39319CAF} = {52380DAA-0F4A-4D97-8E57-98DF39319CAF}
|
|
||||||
EndProjectSection
|
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NetworkAPI", "Network\NetworkAPI\NetworkAPI.vcxproj", "{460D625F-2AC9-4559-B809-0BA89CEAEDF4}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NetworkAPI", "Network\NetworkAPI\NetworkAPI.vcxproj", "{460D625F-2AC9-4559-B809-0BA89CEAEDF4}"
|
||||||
EndProject
|
EndProject
|
||||||
|
@ -44,10 +39,10 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GameProtocols", "Game\GameP
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DanBiasServerLauncher", "Game\DanBiasServerLauncher\DanBiasServerLauncher.vcxproj", "{060B1890-CBF3-4808-BA99-A4776222093B}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DanBiasServerLauncher", "Game\DanBiasServerLauncher\DanBiasServerLauncher.vcxproj", "{060B1890-CBF3-4808-BA99-A4776222093B}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Physics lab", "Physics lab\Physics lab.vcxproj", "{5128BD77-6472-4C4A-BE6F-724AD0E589C2}"
|
|
||||||
EndProject
|
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "aDanBiasGameLauncher", "Game\aDanBiasGameLauncher\aDanBiasGameLauncher.vcxproj", "{666FEA52-975F-41CD-B224-B19AF3C0ABBA}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "aDanBiasGameLauncher", "Game\aDanBiasGameLauncher\aDanBiasGameLauncher.vcxproj", "{666FEA52-975F-41CD-B224-B19AF3C0ABBA}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GameServer", "Game\GameServer\GameServer.vcxproj", "{143BD516-20A1-4890-A3E4-F8BFD02220E7}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Mixed Platforms = Debug|Mixed Platforms
|
Debug|Mixed Platforms = Debug|Mixed Platforms
|
||||||
|
@ -214,18 +209,6 @@ Global
|
||||||
{B1195BB9-B3A5-47F0-906C-8DEA384D1520}.Release|Win32.Build.0 = Release|Win32
|
{B1195BB9-B3A5-47F0-906C-8DEA384D1520}.Release|Win32.Build.0 = Release|Win32
|
||||||
{B1195BB9-B3A5-47F0-906C-8DEA384D1520}.Release|x64.ActiveCfg = Release|x64
|
{B1195BB9-B3A5-47F0-906C-8DEA384D1520}.Release|x64.ActiveCfg = Release|x64
|
||||||
{B1195BB9-B3A5-47F0-906C-8DEA384D1520}.Release|x64.Build.0 = Release|x64
|
{B1195BB9-B3A5-47F0-906C-8DEA384D1520}.Release|x64.Build.0 = Release|x64
|
||||||
{52380DAA-0F4A-4D97-8E57-98DF39319CAF}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
|
|
||||||
{52380DAA-0F4A-4D97-8E57-98DF39319CAF}.Debug|Mixed Platforms.Build.0 = Debug|Win32
|
|
||||||
{52380DAA-0F4A-4D97-8E57-98DF39319CAF}.Debug|Win32.ActiveCfg = Debug|Win32
|
|
||||||
{52380DAA-0F4A-4D97-8E57-98DF39319CAF}.Debug|Win32.Build.0 = Debug|Win32
|
|
||||||
{52380DAA-0F4A-4D97-8E57-98DF39319CAF}.Debug|x64.ActiveCfg = Debug|x64
|
|
||||||
{52380DAA-0F4A-4D97-8E57-98DF39319CAF}.Debug|x64.Build.0 = Debug|x64
|
|
||||||
{52380DAA-0F4A-4D97-8E57-98DF39319CAF}.Release|Mixed Platforms.ActiveCfg = Release|Win32
|
|
||||||
{52380DAA-0F4A-4D97-8E57-98DF39319CAF}.Release|Mixed Platforms.Build.0 = Release|Win32
|
|
||||||
{52380DAA-0F4A-4D97-8E57-98DF39319CAF}.Release|Win32.ActiveCfg = Release|Win32
|
|
||||||
{52380DAA-0F4A-4D97-8E57-98DF39319CAF}.Release|Win32.Build.0 = Release|Win32
|
|
||||||
{52380DAA-0F4A-4D97-8E57-98DF39319CAF}.Release|x64.ActiveCfg = Release|x64
|
|
||||||
{52380DAA-0F4A-4D97-8E57-98DF39319CAF}.Release|x64.Build.0 = Release|x64
|
|
||||||
{8690FDDF-C5B7-4C42-A337-BD5243F29B85}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
|
{8690FDDF-C5B7-4C42-A337-BD5243F29B85}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
|
||||||
{8690FDDF-C5B7-4C42-A337-BD5243F29B85}.Debug|Mixed Platforms.Build.0 = Debug|Win32
|
{8690FDDF-C5B7-4C42-A337-BD5243F29B85}.Debug|Mixed Platforms.Build.0 = Debug|Win32
|
||||||
{8690FDDF-C5B7-4C42-A337-BD5243F29B85}.Debug|Win32.ActiveCfg = Debug|Win32
|
{8690FDDF-C5B7-4C42-A337-BD5243F29B85}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
|
@ -274,18 +257,6 @@ Global
|
||||||
{060B1890-CBF3-4808-BA99-A4776222093B}.Release|Win32.Build.0 = Release|Win32
|
{060B1890-CBF3-4808-BA99-A4776222093B}.Release|Win32.Build.0 = Release|Win32
|
||||||
{060B1890-CBF3-4808-BA99-A4776222093B}.Release|x64.ActiveCfg = Release|x64
|
{060B1890-CBF3-4808-BA99-A4776222093B}.Release|x64.ActiveCfg = Release|x64
|
||||||
{060B1890-CBF3-4808-BA99-A4776222093B}.Release|x64.Build.0 = Release|x64
|
{060B1890-CBF3-4808-BA99-A4776222093B}.Release|x64.Build.0 = Release|x64
|
||||||
{5128BD77-6472-4C4A-BE6F-724AD0E589C2}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
|
|
||||||
{5128BD77-6472-4C4A-BE6F-724AD0E589C2}.Debug|Mixed Platforms.Build.0 = Debug|Win32
|
|
||||||
{5128BD77-6472-4C4A-BE6F-724AD0E589C2}.Debug|Win32.ActiveCfg = Debug|Win32
|
|
||||||
{5128BD77-6472-4C4A-BE6F-724AD0E589C2}.Debug|Win32.Build.0 = Debug|Win32
|
|
||||||
{5128BD77-6472-4C4A-BE6F-724AD0E589C2}.Debug|x64.ActiveCfg = Debug|x64
|
|
||||||
{5128BD77-6472-4C4A-BE6F-724AD0E589C2}.Debug|x64.Build.0 = Debug|x64
|
|
||||||
{5128BD77-6472-4C4A-BE6F-724AD0E589C2}.Release|Mixed Platforms.ActiveCfg = Release|Win32
|
|
||||||
{5128BD77-6472-4C4A-BE6F-724AD0E589C2}.Release|Mixed Platforms.Build.0 = Release|Win32
|
|
||||||
{5128BD77-6472-4C4A-BE6F-724AD0E589C2}.Release|Win32.ActiveCfg = Release|Win32
|
|
||||||
{5128BD77-6472-4C4A-BE6F-724AD0E589C2}.Release|Win32.Build.0 = Release|Win32
|
|
||||||
{5128BD77-6472-4C4A-BE6F-724AD0E589C2}.Release|x64.ActiveCfg = Release|x64
|
|
||||||
{5128BD77-6472-4C4A-BE6F-724AD0E589C2}.Release|x64.Build.0 = Release|x64
|
|
||||||
{666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
|
{666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
|
||||||
{666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Debug|Mixed Platforms.Build.0 = Debug|Win32
|
{666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Debug|Mixed Platforms.Build.0 = Debug|Win32
|
||||||
{666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Debug|Win32.ActiveCfg = Debug|Win32
|
{666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
|
@ -298,6 +269,18 @@ Global
|
||||||
{666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Release|Win32.Build.0 = Release|Win32
|
{666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Release|Win32.Build.0 = Release|Win32
|
||||||
{666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Release|x64.ActiveCfg = Release|x64
|
{666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Release|x64.ActiveCfg = Release|x64
|
||||||
{666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Release|x64.Build.0 = Release|x64
|
{666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Release|x64.Build.0 = Release|x64
|
||||||
|
{143BD516-20A1-4890-A3E4-F8BFD02220E7}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
|
||||||
|
{143BD516-20A1-4890-A3E4-F8BFD02220E7}.Debug|Mixed Platforms.Build.0 = Debug|Win32
|
||||||
|
{143BD516-20A1-4890-A3E4-F8BFD02220E7}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
|
{143BD516-20A1-4890-A3E4-F8BFD02220E7}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
|
{143BD516-20A1-4890-A3E4-F8BFD02220E7}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{143BD516-20A1-4890-A3E4-F8BFD02220E7}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{143BD516-20A1-4890-A3E4-F8BFD02220E7}.Release|Mixed Platforms.ActiveCfg = Release|Win32
|
||||||
|
{143BD516-20A1-4890-A3E4-F8BFD02220E7}.Release|Mixed Platforms.Build.0 = Release|Win32
|
||||||
|
{143BD516-20A1-4890-A3E4-F8BFD02220E7}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
|
{143BD516-20A1-4890-A3E4-F8BFD02220E7}.Release|Win32.Build.0 = Release|Win32
|
||||||
|
{143BD516-20A1-4890-A3E4-F8BFD02220E7}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{143BD516-20A1-4890-A3E4-F8BFD02220E7}.Release|x64.Build.0 = Release|x64
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
@ -309,9 +292,10 @@ Global
|
||||||
{460D625F-2AC9-4559-B809-0BA89CEAEDF4} = {C27B926E-B3EF-4990-8822-47580E43A0BE}
|
{460D625F-2AC9-4559-B809-0BA89CEAEDF4} = {C27B926E-B3EF-4990-8822-47580E43A0BE}
|
||||||
{2A1BC987-AF42-4500-802D-89CD32FC1309} = {20720CA7-795C-45AD-A302-9383A6DD503A}
|
{2A1BC987-AF42-4500-802D-89CD32FC1309} = {20720CA7-795C-45AD-A302-9383A6DD503A}
|
||||||
{B1195BB9-B3A5-47F0-906C-8DEA384D1520} = {20720CA7-795C-45AD-A302-9383A6DD503A}
|
{B1195BB9-B3A5-47F0-906C-8DEA384D1520} = {20720CA7-795C-45AD-A302-9383A6DD503A}
|
||||||
{52380DAA-0F4A-4D97-8E57-98DF39319CAF} = {20720CA7-795C-45AD-A302-9383A6DD503A}
|
|
||||||
{8690FDDF-C5B7-4C42-A337-BD5243F29B85} = {20720CA7-795C-45AD-A302-9383A6DD503A}
|
{8690FDDF-C5B7-4C42-A337-BD5243F29B85} = {20720CA7-795C-45AD-A302-9383A6DD503A}
|
||||||
{DA2AA800-ED64-4649-8B3B-E7F1E3968B78} = {20720CA7-795C-45AD-A302-9383A6DD503A}
|
{DA2AA800-ED64-4649-8B3B-E7F1E3968B78} = {20720CA7-795C-45AD-A302-9383A6DD503A}
|
||||||
{060B1890-CBF3-4808-BA99-A4776222093B} = {20720CA7-795C-45AD-A302-9383A6DD503A}
|
{060B1890-CBF3-4808-BA99-A4776222093B} = {20720CA7-795C-45AD-A302-9383A6DD503A}
|
||||||
|
{666FEA52-975F-41CD-B224-B19AF3C0ABBA} = {20720CA7-795C-45AD-A302-9383A6DD503A}
|
||||||
|
{143BD516-20A1-4890-A3E4-F8BFD02220E7} = {20720CA7-795C-45AD-A302-9383A6DD503A}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
<diagram program="umlet" version="12.2">
|
<diagram program="umlet" version="12.1">
|
||||||
<zoom_level>10</zoom_level>
|
<zoom_level>10</zoom_level>
|
||||||
<element>
|
<element>
|
||||||
<id>UMLClass</id>
|
<id>UMLClass</id>
|
||||||
<coordinates>
|
<coordinates>
|
||||||
<x>530</x>
|
<x>610</x>
|
||||||
<y>320</y>
|
<y>340</y>
|
||||||
<w>100</w>
|
<w>100</w>
|
||||||
<h>30</h>
|
<h>30</h>
|
||||||
</coordinates>
|
</coordinates>
|
||||||
|
@ -16,20 +16,8 @@
|
||||||
<element>
|
<element>
|
||||||
<id>UMLClass</id>
|
<id>UMLClass</id>
|
||||||
<coordinates>
|
<coordinates>
|
||||||
<x>530</x>
|
<x>580</x>
|
||||||
<y>250</y>
|
<y>480</y>
|
||||||
<w>100</w>
|
|
||||||
<h>30</h>
|
|
||||||
</coordinates>
|
|
||||||
<panel_attributes>MainLobby
|
|
||||||
</panel_attributes>
|
|
||||||
<additional_attributes/>
|
|
||||||
</element>
|
|
||||||
<element>
|
|
||||||
<id>UMLClass</id>
|
|
||||||
<coordinates>
|
|
||||||
<x>510</x>
|
|
||||||
<y>500</y>
|
|
||||||
<w>160</w>
|
<w>160</w>
|
||||||
<h>80</h>
|
<h>80</h>
|
||||||
</coordinates>
|
</coordinates>
|
||||||
|
@ -41,89 +29,34 @@
|
||||||
<additional_attributes/>
|
<additional_attributes/>
|
||||||
</element>
|
</element>
|
||||||
<element>
|
<element>
|
||||||
<id>UMLClass</id>
|
<type>com.umlet.element.Relation</type>
|
||||||
|
<coordinates>
|
||||||
|
<x>620</x>
|
||||||
|
<y>340</y>
|
||||||
|
<w>60</w>
|
||||||
|
<h>160</h>
|
||||||
|
</coordinates>
|
||||||
|
<panel_attributes>lt=->>>></panel_attributes>
|
||||||
|
<additional_attributes>30;140;40;30</additional_attributes>
|
||||||
|
</element>
|
||||||
|
<element>
|
||||||
|
<type>com.umlet.element.Relation</type>
|
||||||
<coordinates>
|
<coordinates>
|
||||||
<x>710</x>
|
<x>710</x>
|
||||||
<y>320</y>
|
<y>480</y>
|
||||||
<w>100</w>
|
<w>100</w>
|
||||||
<h>30</h>
|
|
||||||
</coordinates>
|
|
||||||
<panel_attributes>LobbyClient</panel_attributes>
|
|
||||||
<additional_attributes/>
|
|
||||||
</element>
|
|
||||||
<element>
|
|
||||||
<type>com.umlet.element.Relation</type>
|
|
||||||
<coordinates>
|
|
||||||
<x>550</x>
|
|
||||||
<y>250</y>
|
|
||||||
<w>50</w>
|
|
||||||
<h>90</h>
|
|
||||||
</coordinates>
|
|
||||||
<panel_attributes>lt=->>>></panel_attributes>
|
|
||||||
<additional_attributes>30;70;30;30</additional_attributes>
|
|
||||||
</element>
|
|
||||||
<element>
|
|
||||||
<type>com.umlet.element.Relation</type>
|
|
||||||
<coordinates>
|
|
||||||
<x>550</x>
|
|
||||||
<y>420</y>
|
|
||||||
<w>50</w>
|
|
||||||
<h>100</h>
|
|
||||||
</coordinates>
|
|
||||||
<panel_attributes>lt=->>>></panel_attributes>
|
|
||||||
<additional_attributes>30;80;30;30</additional_attributes>
|
|
||||||
</element>
|
|
||||||
<element>
|
|
||||||
<type>com.umlet.element.Relation</type>
|
|
||||||
<coordinates>
|
|
||||||
<x>600</x>
|
|
||||||
<y>300</y>
|
|
||||||
<w>130</w>
|
|
||||||
<h>50</h>
|
<h>50</h>
|
||||||
</coordinates>
|
</coordinates>
|
||||||
<panel_attributes>lt=>>>-</panel_attributes>
|
<panel_attributes>lt=>>>>-</panel_attributes>
|
||||||
<additional_attributes>110;30;30;30</additional_attributes>
|
<additional_attributes>80;30;30;30</additional_attributes>
|
||||||
</element>
|
|
||||||
<element>
|
|
||||||
<type>com.umlet.element.Relation</type>
|
|
||||||
<coordinates>
|
|
||||||
<x>600</x>
|
|
||||||
<y>230</y>
|
|
||||||
<w>180</w>
|
|
||||||
<h>110</h>
|
|
||||||
</coordinates>
|
|
||||||
<panel_attributes>lt=>>>-</panel_attributes>
|
|
||||||
<additional_attributes>160;90;160;30;30;30</additional_attributes>
|
|
||||||
</element>
|
|
||||||
<element>
|
|
||||||
<type>com.umlet.element.Relation</type>
|
|
||||||
<coordinates>
|
|
||||||
<x>640</x>
|
|
||||||
<y>410</y>
|
|
||||||
<w>140</w>
|
|
||||||
<h>140</h>
|
|
||||||
</coordinates>
|
|
||||||
<panel_attributes>lt=>>>-</panel_attributes>
|
|
||||||
<additional_attributes>120;30;120;120;30;120</additional_attributes>
|
|
||||||
</element>
|
|
||||||
<element>
|
|
||||||
<type>com.umlet.element.Relation</type>
|
|
||||||
<coordinates>
|
|
||||||
<x>610</x>
|
|
||||||
<y>140</y>
|
|
||||||
<w>400</w>
|
|
||||||
<h>150</h>
|
|
||||||
</coordinates>
|
|
||||||
<panel_attributes>lt=<<.</panel_attributes>
|
|
||||||
<additional_attributes>380;130;170;130;170;30;30;30</additional_attributes>
|
|
||||||
</element>
|
</element>
|
||||||
<element>
|
<element>
|
||||||
<id>UMLClass</id>
|
<id>UMLClass</id>
|
||||||
<coordinates>
|
<coordinates>
|
||||||
<x>520</x>
|
<x>600</x>
|
||||||
<y>160</y>
|
<y>180</y>
|
||||||
<w>120</w>
|
<w>120</w>
|
||||||
<h>30</h>
|
<h>120</h>
|
||||||
</coordinates>
|
</coordinates>
|
||||||
<panel_attributes>GameServer</panel_attributes>
|
<panel_attributes>GameServer</panel_attributes>
|
||||||
<additional_attributes/>
|
<additional_attributes/>
|
||||||
|
@ -131,42 +64,19 @@
|
||||||
<element>
|
<element>
|
||||||
<type>com.umlet.element.Relation</type>
|
<type>com.umlet.element.Relation</type>
|
||||||
<coordinates>
|
<coordinates>
|
||||||
<x>550</x>
|
<x>630</x>
|
||||||
<y>160</y>
|
<y>270</y>
|
||||||
<w>50</w>
|
<w>50</w>
|
||||||
<h>110</h>
|
<h>90</h>
|
||||||
</coordinates>
|
</coordinates>
|
||||||
<panel_attributes>lt=>>>>-</panel_attributes>
|
<panel_attributes>lt=>>>>-</panel_attributes>
|
||||||
<additional_attributes>30;90;30;30</additional_attributes>
|
<additional_attributes>30;70;30;30</additional_attributes>
|
||||||
</element>
|
|
||||||
<element>
|
|
||||||
<type>com.umlet.element.Relation</type>
|
|
||||||
<coordinates>
|
|
||||||
<x>750</x>
|
|
||||||
<y>260</y>
|
|
||||||
<w>260</w>
|
|
||||||
<h>80</h>
|
|
||||||
</coordinates>
|
|
||||||
<panel_attributes>lt=<<.</panel_attributes>
|
|
||||||
<additional_attributes>240;30;30;30;30;60</additional_attributes>
|
|
||||||
</element>
|
|
||||||
<element>
|
|
||||||
<type>com.umlet.element.Package</type>
|
|
||||||
<coordinates>
|
|
||||||
<x>990</x>
|
|
||||||
<y>250</y>
|
|
||||||
<w>120</w>
|
|
||||||
<h>50</h>
|
|
||||||
</coordinates>
|
|
||||||
<panel_attributes>NetworkAPI
|
|
||||||
bg=#a21aff</panel_attributes>
|
|
||||||
<additional_attributes/>
|
|
||||||
</element>
|
</element>
|
||||||
<element>
|
<element>
|
||||||
<id>UMLClass</id>
|
<id>UMLClass</id>
|
||||||
<coordinates>
|
<coordinates>
|
||||||
<x>510</x>
|
<x>590</x>
|
||||||
<y>20</y>
|
<y>100</y>
|
||||||
<w>130</w>
|
<w>130</w>
|
||||||
<h>40</h>
|
<h>40</h>
|
||||||
</coordinates>
|
</coordinates>
|
||||||
|
@ -177,22 +87,22 @@ DanBiasServerAPI</panel_attributes>
|
||||||
<element>
|
<element>
|
||||||
<type>com.umlet.element.Relation</type>
|
<type>com.umlet.element.Relation</type>
|
||||||
<coordinates>
|
<coordinates>
|
||||||
<x>550</x>
|
<x>630</x>
|
||||||
<y>30</y>
|
<y>110</y>
|
||||||
<w>50</w>
|
<w>50</w>
|
||||||
<h>150</h>
|
<h>90</h>
|
||||||
</coordinates>
|
</coordinates>
|
||||||
<panel_attributes>lt=>>>>-
|
<panel_attributes>lt=>>>>-
|
||||||
</panel_attributes>
|
</panel_attributes>
|
||||||
<additional_attributes>30;130;30;30</additional_attributes>
|
<additional_attributes>30;70;30;30</additional_attributes>
|
||||||
</element>
|
</element>
|
||||||
<element>
|
<element>
|
||||||
<id>UMLClass</id>
|
<id>UMLClass</id>
|
||||||
<coordinates>
|
<coordinates>
|
||||||
<x>300</x>
|
<x>1060</x>
|
||||||
<y>320</y>
|
<y>330</y>
|
||||||
<w>120</w>
|
<w>120</w>
|
||||||
<h>30</h>
|
<h>50</h>
|
||||||
</coordinates>
|
</coordinates>
|
||||||
<panel_attributes>NetworkSession</panel_attributes>
|
<panel_attributes>NetworkSession</panel_attributes>
|
||||||
<additional_attributes/>
|
<additional_attributes/>
|
||||||
|
@ -200,41 +110,41 @@ DanBiasServerAPI</panel_attributes>
|
||||||
<element>
|
<element>
|
||||||
<type>com.umlet.element.Relation</type>
|
<type>com.umlet.element.Relation</type>
|
||||||
<coordinates>
|
<coordinates>
|
||||||
<x>330</x>
|
<x>690</x>
|
||||||
<y>230</y>
|
<y>220</y>
|
||||||
<w>220</w>
|
<w>390</w>
|
||||||
<h>110</h>
|
<h>50</h>
|
||||||
</coordinates>
|
</coordinates>
|
||||||
<panel_attributes>lt=->>>>></panel_attributes>
|
<panel_attributes>lt=-<<<<</panel_attributes>
|
||||||
<additional_attributes>200;30;30;30;30;90</additional_attributes>
|
<additional_attributes>30;30;370;30</additional_attributes>
|
||||||
</element>
|
</element>
|
||||||
<element>
|
<element>
|
||||||
<type>com.umlet.element.Relation</type>
|
<type>com.umlet.element.Relation</type>
|
||||||
<coordinates>
|
<coordinates>
|
||||||
<x>390</x>
|
<x>680</x>
|
||||||
<y>300</y>
|
<y>320</y>
|
||||||
<w>160</w>
|
<w>400</w>
|
||||||
<h>50</h>
|
<h>50</h>
|
||||||
</coordinates>
|
</coordinates>
|
||||||
<panel_attributes>lt=->>>>></panel_attributes>
|
<panel_attributes>lt=->>>>></panel_attributes>
|
||||||
<additional_attributes>140;30;30;30</additional_attributes>
|
<additional_attributes>30;30;380;30</additional_attributes>
|
||||||
</element>
|
</element>
|
||||||
<element>
|
<element>
|
||||||
<type>com.umlet.element.Relation</type>
|
<type>com.umlet.element.Relation</type>
|
||||||
<coordinates>
|
<coordinates>
|
||||||
<x>330</x>
|
<x>690</x>
|
||||||
<y>320</y>
|
<y>340</y>
|
||||||
<w>200</w>
|
<w>390</w>
|
||||||
<h>210</h>
|
<h>160</h>
|
||||||
</coordinates>
|
</coordinates>
|
||||||
<panel_attributes>lt=->>>>></panel_attributes>
|
<panel_attributes>lt=->>>>></panel_attributes>
|
||||||
<additional_attributes>180;190;30;190;30;30</additional_attributes>
|
<additional_attributes>30;140;40;40;370;30</additional_attributes>
|
||||||
</element>
|
</element>
|
||||||
<element>
|
<element>
|
||||||
<type>com.umlet.element.Package</type>
|
<type>com.umlet.element.Package</type>
|
||||||
<coordinates>
|
<coordinates>
|
||||||
<x>990</x>
|
<x>460</x>
|
||||||
<y>370</y>
|
<y>640</y>
|
||||||
<w>120</w>
|
<w>120</w>
|
||||||
<h>50</h>
|
<h>50</h>
|
||||||
</coordinates>
|
</coordinates>
|
||||||
|
@ -245,164 +155,19 @@ bg=blue</panel_attributes>
|
||||||
<element>
|
<element>
|
||||||
<type>com.umlet.element.Relation</type>
|
<type>com.umlet.element.Relation</type>
|
||||||
<coordinates>
|
<coordinates>
|
||||||
<x>750</x>
|
<x>370</x>
|
||||||
<y>320</y>
|
<y>530</y>
|
||||||
<w>260</w>
|
<w>350</w>
|
||||||
<h>90</h>
|
<h>290</h>
|
||||||
</coordinates>
|
</coordinates>
|
||||||
<panel_attributes>lt=<<.</panel_attributes>
|
<panel_attributes>lt=<<.</panel_attributes>
|
||||||
<additional_attributes>240;70;30;70;30;30</additional_attributes>
|
<additional_attributes>90;150;30;270;330;240;240;30</additional_attributes>
|
||||||
</element>
|
|
||||||
<element>
|
|
||||||
<type>com.umlet.element.Package</type>
|
|
||||||
<coordinates>
|
|
||||||
<x>990</x>
|
|
||||||
<y>310</y>
|
|
||||||
<w>120</w>
|
|
||||||
<h>40</h>
|
|
||||||
</coordinates>
|
|
||||||
<panel_attributes>PhysicsAPI
|
|
||||||
bg=blue
|
|
||||||
--
|
|
||||||
</panel_attributes>
|
|
||||||
<additional_attributes/>
|
|
||||||
</element>
|
|
||||||
<element>
|
|
||||||
<type>com.umlet.element.Relation</type>
|
|
||||||
<coordinates>
|
|
||||||
<x>780</x>
|
|
||||||
<y>300</y>
|
|
||||||
<w>230</w>
|
|
||||||
<h>50</h>
|
|
||||||
</coordinates>
|
|
||||||
<panel_attributes>lt=.<<</panel_attributes>
|
|
||||||
<additional_attributes>210;30;30;30</additional_attributes>
|
|
||||||
</element>
|
|
||||||
<element>
|
|
||||||
<type>com.umlet.element.Relation</type>
|
|
||||||
<coordinates>
|
|
||||||
<x>640</x>
|
|
||||||
<y>380</y>
|
|
||||||
<w>370</w>
|
|
||||||
<h>190</h>
|
|
||||||
</coordinates>
|
|
||||||
<panel_attributes>lt=<<.</panel_attributes>
|
|
||||||
<additional_attributes>350;30;190;30;190;170;30;170</additional_attributes>
|
|
||||||
</element>
|
</element>
|
||||||
<element>
|
<element>
|
||||||
<id>UMLClass</id>
|
<id>UMLClass</id>
|
||||||
<coordinates>
|
<coordinates>
|
||||||
<x>320</x>
|
<x>790</x>
|
||||||
<y>120</y>
|
<y>500</y>
|
||||||
<w>130</w>
|
|
||||||
<h>90</h>
|
|
||||||
</coordinates>
|
|
||||||
<panel_attributes>ServerInitReader
|
|
||||||
--
|
|
||||||
Helper to load ini files to server
|
|
||||||
|
|
||||||
elementstyle=wordwrap
|
|
||||||
</panel_attributes>
|
|
||||||
<additional_attributes/>
|
|
||||||
</element>
|
|
||||||
<element>
|
|
||||||
<type>com.umlet.element.Relation</type>
|
|
||||||
<coordinates>
|
|
||||||
<x>420</x>
|
|
||||||
<y>140</y>
|
|
||||||
<w>120</w>
|
|
||||||
<h>50</h>
|
|
||||||
</coordinates>
|
|
||||||
<panel_attributes>lt=>>.
|
|
||||||
</panel_attributes>
|
|
||||||
<additional_attributes>100;30;30;30</additional_attributes>
|
|
||||||
</element>
|
|
||||||
<element>
|
|
||||||
<id>UMLClass</id>
|
|
||||||
<coordinates>
|
|
||||||
<x>510</x>
|
|
||||||
<y>400</y>
|
|
||||||
<w>160</w>
|
|
||||||
<h>50</h>
|
|
||||||
</coordinates>
|
|
||||||
<panel_attributes>GameSessionManager
|
|
||||||
--
|
|
||||||
/Creates game sessions/</panel_attributes>
|
|
||||||
<additional_attributes/>
|
|
||||||
</element>
|
|
||||||
<element>
|
|
||||||
<type>com.umlet.element.Relation</type>
|
|
||||||
<coordinates>
|
|
||||||
<x>550</x>
|
|
||||||
<y>320</y>
|
|
||||||
<w>50</w>
|
|
||||||
<h>100</h>
|
|
||||||
</coordinates>
|
|
||||||
<panel_attributes>lt=>>-</panel_attributes>
|
|
||||||
<additional_attributes>30;30;30;80</additional_attributes>
|
|
||||||
</element>
|
|
||||||
<element>
|
|
||||||
<type>com.umlet.element.Package</type>
|
|
||||||
<coordinates>
|
|
||||||
<x>990</x>
|
|
||||||
<y>430</y>
|
|
||||||
<w>120</w>
|
|
||||||
<h>40</h>
|
|
||||||
</coordinates>
|
|
||||||
<panel_attributes>ProtocolManager
|
|
||||||
bg=#aaaaa</panel_attributes>
|
|
||||||
<additional_attributes/>
|
|
||||||
</element>
|
|
||||||
<element>
|
|
||||||
<type>com.umlet.element.Relation</type>
|
|
||||||
<coordinates>
|
|
||||||
<x>310</x>
|
|
||||||
<y>320</y>
|
|
||||||
<w>770</w>
|
|
||||||
<h>300</h>
|
|
||||||
</coordinates>
|
|
||||||
<panel_attributes>lt=<<.</panel_attributes>
|
|
||||||
<additional_attributes>750;150;750;280;30;280;30;30</additional_attributes>
|
|
||||||
</element>
|
|
||||||
<element>
|
|
||||||
<type>com.umlet.element.Relation</type>
|
|
||||||
<coordinates>
|
|
||||||
<x>1080</x>
|
|
||||||
<y>260</y>
|
|
||||||
<w>70</w>
|
|
||||||
<h>210</h>
|
|
||||||
</coordinates>
|
|
||||||
<panel_attributes>lt=<<.</panel_attributes>
|
|
||||||
<additional_attributes>30;190;50;190;50;30;30;30</additional_attributes>
|
|
||||||
</element>
|
|
||||||
<element>
|
|
||||||
<id>UMLClass</id>
|
|
||||||
<coordinates>
|
|
||||||
<x>160</x>
|
|
||||||
<y>310</y>
|
|
||||||
<w>120</w>
|
|
||||||
<h>40</h>
|
|
||||||
</coordinates>
|
|
||||||
<panel_attributes>/<<interface>>/
|
|
||||||
INetworkSession</panel_attributes>
|
|
||||||
<additional_attributes/>
|
|
||||||
</element>
|
|
||||||
<element>
|
|
||||||
<type>com.umlet.element.Relation</type>
|
|
||||||
<coordinates>
|
|
||||||
<x>250</x>
|
|
||||||
<y>300</y>
|
|
||||||
<w>70</w>
|
|
||||||
<h>50</h>
|
|
||||||
</coordinates>
|
|
||||||
<panel_attributes>lt=->>>>></panel_attributes>
|
|
||||||
<additional_attributes>50;30;30;30</additional_attributes>
|
|
||||||
</element>
|
|
||||||
<element>
|
|
||||||
<id>UMLClass</id>
|
|
||||||
<coordinates>
|
|
||||||
<x>710</x>
|
|
||||||
<y>410</y>
|
|
||||||
<w>100</w>
|
<w>100</w>
|
||||||
<h>30</h>
|
<h>30</h>
|
||||||
</coordinates>
|
</coordinates>
|
||||||
|
@ -412,28 +177,91 @@ INetworkSession</panel_attributes>
|
||||||
<element>
|
<element>
|
||||||
<type>com.umlet.element.Relation</type>
|
<type>com.umlet.element.Relation</type>
|
||||||
<coordinates>
|
<coordinates>
|
||||||
<x>730</x>
|
<x>670</x>
|
||||||
<y>320</y>
|
<y>530</y>
|
||||||
<w>50</w>
|
<w>150</w>
|
||||||
<h>110</h>
|
<h>180</h>
|
||||||
</coordinates>
|
</coordinates>
|
||||||
<panel_attributes>lt=>>>-</panel_attributes>
|
<panel_attributes>lt=<<.</panel_attributes>
|
||||||
<additional_attributes>30;30;30;90</additional_attributes>
|
<additional_attributes>130;160;30;30</additional_attributes>
|
||||||
|
</element>
|
||||||
|
<element>
|
||||||
|
<type>com.umlet.element.Package</type>
|
||||||
|
<coordinates>
|
||||||
|
<x>800</x>
|
||||||
|
<y>670</y>
|
||||||
|
<w>120</w>
|
||||||
|
<h>40</h>
|
||||||
|
</coordinates>
|
||||||
|
<panel_attributes>GameProtocols
|
||||||
|
bg=#aaaaa</panel_attributes>
|
||||||
|
<additional_attributes/>
|
||||||
|
</element>
|
||||||
|
<element>
|
||||||
|
<type>com.umlet.element.Package</type>
|
||||||
|
<coordinates>
|
||||||
|
<x>1040</x>
|
||||||
|
<y>200</y>
|
||||||
|
<w>160</w>
|
||||||
|
<h>190</h>
|
||||||
|
</coordinates>
|
||||||
|
<panel_attributes>NetworkAPI
|
||||||
|
bg=#a21aff</panel_attributes>
|
||||||
|
<additional_attributes/>
|
||||||
</element>
|
</element>
|
||||||
<element>
|
<element>
|
||||||
<id>UMLClass</id>
|
<id>UMLClass</id>
|
||||||
<coordinates>
|
<coordinates>
|
||||||
<x>150</x>
|
<x>1060</x>
|
||||||
<y>420</y>
|
<y>280</y>
|
||||||
<w>160</w>
|
<w>120</w>
|
||||||
<h>50</h>
|
<h>40</h>
|
||||||
</coordinates>
|
</coordinates>
|
||||||
<panel_attributes>MapManager
|
<panel_attributes>NetworkClient</panel_attributes>
|
||||||
--
|
|
||||||
Manages all map stuff.
|
|
||||||
|
|
||||||
elementstyle=wordwrap
|
|
||||||
</panel_attributes>
|
|
||||||
<additional_attributes/>
|
<additional_attributes/>
|
||||||
</element>
|
</element>
|
||||||
|
<element>
|
||||||
|
<id>UMLClass</id>
|
||||||
|
<coordinates>
|
||||||
|
<x>1060</x>
|
||||||
|
<y>230</y>
|
||||||
|
<w>120</w>
|
||||||
|
<h>40</h>
|
||||||
|
</coordinates>
|
||||||
|
<panel_attributes>NetworkServer</panel_attributes>
|
||||||
|
<additional_attributes/>
|
||||||
|
</element>
|
||||||
|
<element>
|
||||||
|
<type>com.umlet.element.Relation</type>
|
||||||
|
<coordinates>
|
||||||
|
<x>690</x>
|
||||||
|
<y>240</y>
|
||||||
|
<w>390</w>
|
||||||
|
<h>80</h>
|
||||||
|
</coordinates>
|
||||||
|
<panel_attributes>lt=-></panel_attributes>
|
||||||
|
<additional_attributes>30;30;200;30;200;60;370;60</additional_attributes>
|
||||||
|
</element>
|
||||||
|
<element>
|
||||||
|
<type>com.umlet.element.Relation</type>
|
||||||
|
<coordinates>
|
||||||
|
<x>690</x>
|
||||||
|
<y>260</y>
|
||||||
|
<w>390</w>
|
||||||
|
<h>100</h>
|
||||||
|
</coordinates>
|
||||||
|
<panel_attributes>lt=-<<<<</panel_attributes>
|
||||||
|
<additional_attributes>30;30;180;30;180;80;370;80</additional_attributes>
|
||||||
|
</element>
|
||||||
|
<element>
|
||||||
|
<type>com.umlet.element.Relation</type>
|
||||||
|
<coordinates>
|
||||||
|
<x>860</x>
|
||||||
|
<y>270</y>
|
||||||
|
<w>380</w>
|
||||||
|
<h>260</h>
|
||||||
|
</coordinates>
|
||||||
|
<panel_attributes>lt=>>>-</panel_attributes>
|
||||||
|
<additional_attributes>320;30;360;30;360;230;30;240</additional_attributes>
|
||||||
|
</element>
|
||||||
</diagram>
|
</diagram>
|
||||||
|
|
|
@ -61,18 +61,16 @@ namespace DanBias
|
||||||
return DanBiasClientReturn_Error;
|
return DanBiasClientReturn_Error;
|
||||||
|
|
||||||
m_data->recieverObj = new GameRecieverObject;
|
m_data->recieverObj = new GameRecieverObject;
|
||||||
|
m_data->recieverObj->Connect(desc.port, desc.IP);
|
||||||
|
|
||||||
m_data->recieverObj->nwClient = new Oyster::Network::NetworkClient(m_data->recieverObj, Oyster::Network::NetworkProtocolCallbackType_Object);
|
if (!m_data->recieverObj->IsConnected())
|
||||||
m_data->recieverObj->nwClient->Connect(desc.port, desc.IP);
|
|
||||||
|
|
||||||
if (!m_data->recieverObj->nwClient->IsConnected())
|
|
||||||
{
|
{
|
||||||
// failed to connect
|
// failed to connect
|
||||||
return DanBiasClientReturn_Error;
|
return DanBiasClientReturn_Error;
|
||||||
}
|
}
|
||||||
// Start in lobby state
|
// Start in lobby state
|
||||||
m_data->recieverObj->gameClientState = new Client::LobbyState();
|
m_data->recieverObj->gameClientState = new Client::LobbyState();
|
||||||
if(!m_data->recieverObj->gameClientState->Init(m_data->recieverObj->nwClient))
|
if(!m_data->recieverObj->gameClientState->Init(m_data->recieverObj))
|
||||||
return DanBiasClientReturn_Error;
|
return DanBiasClientReturn_Error;
|
||||||
|
|
||||||
m_data->timer = new Utility::WinTimer(); //why dynamic memory?
|
m_data->timer = new Utility::WinTimer(); //why dynamic memory?
|
||||||
|
@ -157,7 +155,7 @@ namespace DanBias
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
m_data->recieverObj->gameClientState->Init(m_data->recieverObj->nwClient); // send game client
|
m_data->recieverObj->gameClientState->Init(m_data->recieverObj); // send game client
|
||||||
|
|
||||||
}
|
}
|
||||||
return S_OK;
|
return S_OK;
|
||||||
|
@ -184,10 +182,9 @@ namespace DanBias
|
||||||
{
|
{
|
||||||
m_data->recieverObj->gameClientState->Release();
|
m_data->recieverObj->gameClientState->Release();
|
||||||
delete m_data->recieverObj->gameClientState;
|
delete m_data->recieverObj->gameClientState;
|
||||||
m_data->recieverObj->nwClient->Disconnect();
|
m_data->recieverObj->Disconnect();
|
||||||
delete m_data->recieverObj->nwClient;
|
|
||||||
delete m_data->timer;
|
|
||||||
delete m_data->recieverObj;
|
delete m_data->recieverObj;
|
||||||
|
delete m_data->timer;
|
||||||
delete m_data->inputObj;
|
delete m_data->inputObj;
|
||||||
delete m_data;
|
delete m_data;
|
||||||
|
|
||||||
|
|
|
@ -1,24 +1,32 @@
|
||||||
#ifndef DANBIAS_CLIENTRECIEVEROBJECT_H
|
#ifndef DANBIAS_CLIENTRECIEVEROBJECT_H
|
||||||
#define DANBIAS_CLIENTRECIEVEROBJECT_H
|
#define DANBIAS_CLIENTRECIEVEROBJECT_H
|
||||||
|
|
||||||
|
//WTF!? No headers included???
|
||||||
|
|
||||||
namespace DanBias
|
namespace DanBias
|
||||||
{
|
{
|
||||||
inline bool IsLobbyProtocol(short ID) { return (ID >= protocol_LobbyMIN && ID <= protocol_LobbyMAX); }
|
struct GameRecieverObject :public Oyster::Network::NetworkClient
|
||||||
inline bool IsGeneralProtocol(short ID) { return (ID >= protocol_GeneralMIN && ID <= protocol_GeneralMAX); }
|
|
||||||
inline bool IsGameplayProtocol(short ID) { return (ID >= protocol_GameplayMIN && ID <= protocol_GameplayMAX); }
|
|
||||||
|
|
||||||
struct GameRecieverObject :public Oyster::Network::ProtocolRecieverObject
|
|
||||||
{
|
{
|
||||||
Oyster::Network::NetworkClient* nwClient;
|
|
||||||
Client::GameClientState* gameClientState;
|
Client::GameClientState* gameClientState;
|
||||||
|
|
||||||
// receiver function for server messages
|
// receiver function for server messages
|
||||||
// parsing protocols and sending it to the gameState
|
// parsing protocols and sending it to the gameState
|
||||||
void ParseGamePlayEvent(Oyster::Network::CustomNetProtocol& p)
|
void NetworkCallback(Oyster::Network::CustomNetProtocol& p) override
|
||||||
{
|
{
|
||||||
int pType = p[0].value.netInt;
|
int pType = p[0].value.netInt;
|
||||||
switch (pType)
|
switch (pType)
|
||||||
{
|
{
|
||||||
|
case protocol_General_Status:
|
||||||
|
{
|
||||||
|
GameLogic::Protocol_General_Status::States state;
|
||||||
|
state = (GameLogic::Protocol_General_Status::States)p[1].value.netShort;
|
||||||
|
if( state == GameLogic::Protocol_General_Status::States_disconected)
|
||||||
|
{
|
||||||
|
// server disconnected
|
||||||
|
DanBiasGame::Release();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
case protocol_Gameplay_PlayerMovement:
|
case protocol_Gameplay_PlayerMovement:
|
||||||
{
|
{
|
||||||
Client::GameClientState::KeyInput* protocolData = new Client::GameClientState::KeyInput;
|
Client::GameClientState::KeyInput* protocolData = new Client::GameClientState::KeyInput;
|
||||||
|
@ -33,6 +41,19 @@ struct GameRecieverObject :public Oyster::Network::ProtocolRecieverObject
|
||||||
protocolData = NULL;
|
protocolData = NULL;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
//case protocol_Gameplay_PlayerPosition:
|
||||||
|
// {
|
||||||
|
// Client::GameClientState::PlayerPos* protocolData = new Client::GameClientState::PlayerPos;
|
||||||
|
// for(int i = 0; i< 3; i++)
|
||||||
|
// {
|
||||||
|
// protocolData->playerPos[i] = p[i].value.netFloat;
|
||||||
|
// }
|
||||||
|
// if(dynamic_cast<Client::GameState*>(gameClientState))
|
||||||
|
// ((Client::GameState*)gameClientState)->Protocol(protocolData);
|
||||||
|
// delete protocolData;
|
||||||
|
// protocolData = NULL;
|
||||||
|
// }
|
||||||
|
// break;
|
||||||
|
|
||||||
case protocol_Gameplay_ObjectCreate:
|
case protocol_Gameplay_ObjectCreate:
|
||||||
{
|
{
|
||||||
|
@ -85,34 +106,7 @@ struct GameRecieverObject :public Oyster::Network::ProtocolRecieverObject
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
void ParseGeneralEvent(Oyster::Network::CustomNetProtocol& p)
|
|
||||||
{
|
|
||||||
int pType = p[0].value.netInt;
|
|
||||||
switch (pType)
|
|
||||||
{
|
|
||||||
|
|
||||||
case protocol_General_Status:
|
|
||||||
{
|
|
||||||
GameLogic::Protocol_General_Status::States state;
|
|
||||||
state = (GameLogic::Protocol_General_Status::States)p[1].value.netShort;
|
|
||||||
if( state == GameLogic::Protocol_General_Status::States_disconected)
|
|
||||||
{
|
|
||||||
// server disconnected
|
|
||||||
DanBiasGame::Release();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void NetworkCallback(Oyster::Network::CustomNetProtocol& p) override
|
|
||||||
{
|
|
||||||
|
|
||||||
if( IsGameplayProtocol(p[protocol_INDEX_ID].value.netShort) )
|
|
||||||
ParseGamePlayEvent(p);
|
|
||||||
|
|
||||||
if( IsGeneralProtocol(p[protocol_INDEX_ID].value.netShort) )
|
|
||||||
ParseGeneralEvent(p);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,9 +104,11 @@ bool GameState::LoadModels(std::wstring mapFile)
|
||||||
privData->object[privData->object.size() -1 ]->Init(modelData);
|
privData->object[privData->object.size() -1 ]->Init(modelData);
|
||||||
modelData.world = Oyster::Math3D::Float4x4::identity;
|
modelData.world = Oyster::Math3D::Float4x4::identity;
|
||||||
|
|
||||||
|
|
||||||
// add player model
|
// add player model
|
||||||
modelData.world = Oyster::Math3D::Float4x4::identity;
|
modelData.world = Oyster::Math3D::Float4x4::identity;
|
||||||
translate = Oyster::Math3D::TranslationMatrix(Oyster::Math::Float3(0, 15, 0));
|
translate = Oyster::Math3D::TranslationMatrix(Oyster::Math::Float3(0, 15, 0));
|
||||||
|
|
||||||
modelData.world = modelData.world * translate;
|
modelData.world = modelData.world * translate;
|
||||||
modelData.visible = true;
|
modelData.visible = true;
|
||||||
modelData.modelPath = L"..\\Content\\Models\\char_white.dan";
|
modelData.modelPath = L"..\\Content\\Models\\char_white.dan";
|
||||||
|
@ -118,9 +120,6 @@ bool GameState::LoadModels(std::wstring mapFile)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
bool GameState::InitCamera(Oyster::Math::Float3 startPos)
|
bool GameState::InitCamera(Oyster::Math::Float3 startPos)
|
||||||
|
@ -200,6 +199,8 @@ bool GameState::Release()
|
||||||
privData->object[i] = NULL;
|
privData->object[i] = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delete this->camera;
|
||||||
|
|
||||||
delete privData;
|
delete privData;
|
||||||
privData = NULL;
|
privData = NULL;
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -1,68 +0,0 @@
|
||||||
#define NOMINMAX
|
|
||||||
#include "AdminInterface.h"
|
|
||||||
#include <Thread\OysterThread.h>
|
|
||||||
#include <WindowShell.h>
|
|
||||||
#include "..\GameServer.h"
|
|
||||||
#include "..\GameSession\GameSessionManager.h"
|
|
||||||
#include "..\GameSession\GameSession.h"
|
|
||||||
#include "..\Helpers\ServerDataReader.h"
|
|
||||||
#include "..\LobbySessions\LobbyClient.h"
|
|
||||||
#include "..\LobbySessions\NetworkSession.h"
|
|
||||||
#include "..\LobbySessions\GameLobby.h"
|
|
||||||
#include "..\LobbySessions\MainLobby.h"
|
|
||||||
|
|
||||||
using namespace Oyster::Network;
|
|
||||||
using namespace Oyster::Thread;
|
|
||||||
using namespace DanBias;
|
|
||||||
|
|
||||||
struct AdminInstanceData :public IThreadObject
|
|
||||||
{
|
|
||||||
bool isCreated;
|
|
||||||
Oyster::Network::NetworkServer adminServer;
|
|
||||||
NetworkClient* admin;
|
|
||||||
NetworkSession* parentInstance;
|
|
||||||
OysterThread worker;
|
|
||||||
|
|
||||||
bool DoWork() override
|
|
||||||
{
|
|
||||||
//((GameServer*)parentInstance)->serve
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}adminInstanceData;
|
|
||||||
|
|
||||||
void AdminArrived(NetworkClient* adm)
|
|
||||||
{
|
|
||||||
if(adminInstanceData.admin)
|
|
||||||
{
|
|
||||||
delete adm;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
adminInstanceData.admin = adm;
|
|
||||||
adminInstanceData.worker.Create(&adminInstanceData, true, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void AdminInterface::Toggle(bool toggle, NetworkSession* parent)
|
|
||||||
{
|
|
||||||
if(toggle)
|
|
||||||
{
|
|
||||||
if(!parent) return;
|
|
||||||
|
|
||||||
if(adminInstanceData.isCreated) return;
|
|
||||||
|
|
||||||
NetworkServer::INIT_DESC desc;
|
|
||||||
desc.port = 15152;
|
|
||||||
desc.callbackType = NetworkClientCallbackType_Function;
|
|
||||||
desc.recvObj.clientConnectFnc = AdminArrived;
|
|
||||||
|
|
||||||
if(!adminInstanceData.adminServer.Init(desc)) return;
|
|
||||||
adminInstanceData.parentInstance = parent;
|
|
||||||
|
|
||||||
adminInstanceData.adminServer.Start();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
adminInstanceData.adminServer.Shutdown();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,20 +0,0 @@
|
||||||
/////////////////////////////////////////
|
|
||||||
// Created by [Dennis Andersen] [2013] //
|
|
||||||
/////////////////////////////////////////
|
|
||||||
#ifndef DANBIASSERVER_ADMIN_INTERFACE_H
|
|
||||||
#define DANBIASSERVER_ADMIN_INTERFACE_H
|
|
||||||
|
|
||||||
#include <NetworkServer.h>
|
|
||||||
|
|
||||||
namespace DanBias
|
|
||||||
{
|
|
||||||
class NetworkSession;
|
|
||||||
//Global admin
|
|
||||||
class AdminInterface
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static void Toggle(bool toggle, NetworkSession* parent);
|
|
||||||
|
|
||||||
};
|
|
||||||
}
|
|
||||||
#endif // !DANBIASSERVER_ADMIN_INTERFACE_H
|
|
|
@ -1,28 +0,0 @@
|
||||||
/////////////////////////////////////////////////////////////////////
|
|
||||||
// Created by [Dennis Andersen] [2013]
|
|
||||||
/////////////////////////////////////////////////////////////////////
|
|
||||||
#include "DanBiasServerAPI.h"
|
|
||||||
#include "GameServer.h"
|
|
||||||
|
|
||||||
namespace DanBias
|
|
||||||
{
|
|
||||||
|
|
||||||
#pragma region Server Data
|
|
||||||
static GameServer server;
|
|
||||||
#pragma endregion
|
|
||||||
|
|
||||||
|
|
||||||
DanBiasServerReturn DanBiasServerAPI::Initiate()
|
|
||||||
{
|
|
||||||
return server.Create();
|
|
||||||
}
|
|
||||||
DanBiasServerReturn DanBiasServerAPI::Run()
|
|
||||||
{
|
|
||||||
return server.Run();
|
|
||||||
}
|
|
||||||
DanBiasServerReturn DanBiasServerAPI::Release()
|
|
||||||
{
|
|
||||||
return server.Release();
|
|
||||||
}
|
|
||||||
|
|
||||||
} //End namspace DanBias
|
|
|
@ -1,161 +0,0 @@
|
||||||
/////////////////////////////////////////////////////////////////////
|
|
||||||
// Created by [Dennis Andersen] [2013]
|
|
||||||
/////////////////////////////////////////////////////////////////////
|
|
||||||
#define NOMINMAX
|
|
||||||
#include <Windows.h>
|
|
||||||
#include <WindowShell.h>
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
#include "GameServer.h"
|
|
||||||
#include "Helpers\ServerDataReader.h"
|
|
||||||
#include "GameSession\GameSessionManager.h"
|
|
||||||
#include "LobbySessions\LobbyClient.h"
|
|
||||||
#include "GameSession\GameSession.h"
|
|
||||||
#include "AdminInterface\AdminInterface.h"
|
|
||||||
|
|
||||||
#include <Thread\OysterThread.h>
|
|
||||||
#include <Utilities.h>
|
|
||||||
|
|
||||||
#include <CollisionManager.h>
|
|
||||||
|
|
||||||
namespace DanBias
|
|
||||||
{
|
|
||||||
using namespace Oyster::Network;
|
|
||||||
|
|
||||||
GameServer* GameServer::instance = 0;
|
|
||||||
|
|
||||||
void GameServer::NetworkCallback(NetworkClient* client)
|
|
||||||
{
|
|
||||||
static bool myTest = false;
|
|
||||||
static int sessionId = -1;
|
|
||||||
printf("Client with ID [%i] connected.\n", client->GetID());
|
|
||||||
|
|
||||||
if(!myTest)
|
|
||||||
{
|
|
||||||
Utility::DynamicMemory::SmartPointer<LobbyClient> c = new LobbyClient(client);
|
|
||||||
|
|
||||||
GameSessionDescription desc;
|
|
||||||
desc.mapName = L"test";
|
|
||||||
desc.clients.Push(c);
|
|
||||||
desc.exitDestionation = this->mainLobby;
|
|
||||||
if((sessionId = GameSessionManager::AddSession(desc, true)) == 0)
|
|
||||||
printf("Failed to create a game session\n");
|
|
||||||
myTest = true;
|
|
||||||
//myTest = new GameSession();
|
|
||||||
//
|
|
||||||
//DanBias::GameSession::GameSessionDescription desc;
|
|
||||||
//desc.owner = 0;
|
|
||||||
//desc.clients.Push(c);
|
|
||||||
//
|
|
||||||
//if(!myTest->Create(desc)) return;
|
|
||||||
//myTest->Run();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Utility::DynamicMemory::SmartPointer<LobbyClient> c = new LobbyClient(client);
|
|
||||||
GameSessionManager::JoinSession(sessionId, c);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//Utility::DynamicMemory::SmartPointer<LobbyClient> c = new LobbyClient(client);
|
|
||||||
//this->mainLobby->Attach(c, this->mainLobby->GetPostbox());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
GameServer::GameServer()
|
|
||||||
: initiated(0)
|
|
||||||
, running(0)
|
|
||||||
, released(0)
|
|
||||||
, maxClients(0)
|
|
||||||
, mainLobby(0)
|
|
||||||
, server(0)
|
|
||||||
{ this->instance = this; }
|
|
||||||
GameServer::~GameServer()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
DanBiasServerReturn GameServer::Create()
|
|
||||||
{
|
|
||||||
this->server = new NetworkServer();
|
|
||||||
this->mainLobby = new MainLobby();
|
|
||||||
|
|
||||||
InitData data;
|
|
||||||
if(!LoadIniFile(data)) return DanBiasServerReturn_Error;
|
|
||||||
|
|
||||||
NetworkServer::INIT_DESC serverDesc;
|
|
||||||
this->maxClients = data.clients;
|
|
||||||
serverDesc.port = data.port;
|
|
||||||
serverDesc.recvObj = this;
|
|
||||||
serverDesc.callbackType = Oyster::Network::NetworkClientCallbackType_Object;
|
|
||||||
|
|
||||||
if(!this->server->Init(serverDesc)) return DanBiasServerReturn_Error;
|
|
||||||
if(!WindowShell::CreateConsoleWindow()) return DanBiasServerReturn_Error;
|
|
||||||
|
|
||||||
this->initiated = true;
|
|
||||||
return DanBiasServerReturn_Sucess;
|
|
||||||
}
|
|
||||||
DanBiasServerReturn GameServer::Run()
|
|
||||||
{
|
|
||||||
if(this->running) return DanBiasServerReturn_Error;
|
|
||||||
if(this->released) return DanBiasServerReturn_Error;
|
|
||||||
if(!this->initiated) return DanBiasServerReturn_Error;
|
|
||||||
|
|
||||||
if(!this->server->Start()) return DanBiasServerReturn_Error;
|
|
||||||
//Oyster::Thread::OysterThread ioThread;
|
|
||||||
//ioThread.Create(this, true,
|
|
||||||
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
if(!WindowShell::Frame()) break;
|
|
||||||
|
|
||||||
this->mainLobby->Frame();
|
|
||||||
|
|
||||||
if(GetAsyncKeyState(0x51)) //Q for exit
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return DanBiasServerReturn_Sucess;
|
|
||||||
}
|
|
||||||
DanBiasServerReturn GameServer::Release()
|
|
||||||
{
|
|
||||||
GameSessionManager::CloseSession();
|
|
||||||
this->mainLobby->Release();
|
|
||||||
delete this->mainLobby;
|
|
||||||
this->server->Shutdown();
|
|
||||||
delete this->server;
|
|
||||||
this->released = true;
|
|
||||||
return DanBiasServerReturn_Sucess;
|
|
||||||
}
|
|
||||||
|
|
||||||
NetworkSession* GameServer::MainLobbyInstance()
|
|
||||||
{
|
|
||||||
return GameServer::instance->mainLobby;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool GameServer::LoadIniFile(InitData& ini)
|
|
||||||
{
|
|
||||||
std::ifstream in;
|
|
||||||
std::string f = GetInitPath(InitPath_ServerIni);
|
|
||||||
in.open(f, std::ios::in);
|
|
||||||
if(!in.is_open()) return false;
|
|
||||||
|
|
||||||
std::string buffer;
|
|
||||||
while (!in.eof())
|
|
||||||
{
|
|
||||||
in >> buffer;
|
|
||||||
|
|
||||||
if(buffer == "port")
|
|
||||||
{
|
|
||||||
in >> ini.port;
|
|
||||||
}
|
|
||||||
else if(buffer == "clients")
|
|
||||||
{
|
|
||||||
in >> ini.clients;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
in.close();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}//End namespace DanBias
|
|
|
@ -1,50 +0,0 @@
|
||||||
/////////////////////////////////////////////////////////////////////
|
|
||||||
// Created by [Dennis Andersen] [2013]
|
|
||||||
/////////////////////////////////////////////////////////////////////
|
|
||||||
#ifndef DANBIASSERVER_GAME_SERVER_H
|
|
||||||
#define DANBIASSERVER_GAME_SERVER_H
|
|
||||||
|
|
||||||
#include "DanBiasServerAPI.h"
|
|
||||||
#include "LobbySessions\MainLobby.h"
|
|
||||||
#include <NetworkServer.h>
|
|
||||||
#include <NetworkCallbackHelper.h>
|
|
||||||
|
|
||||||
namespace DanBias
|
|
||||||
{
|
|
||||||
class GameServer :public Oyster::Network::ClientConnectedObject
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
GameServer();
|
|
||||||
virtual~GameServer();
|
|
||||||
|
|
||||||
DanBiasServerReturn Create();
|
|
||||||
DanBiasServerReturn Run();
|
|
||||||
DanBiasServerReturn Release();
|
|
||||||
|
|
||||||
static NetworkSession* MainLobbyInstance();
|
|
||||||
|
|
||||||
private:
|
|
||||||
//static void ClientConnectCallbackFunction(Oyster::Network::NetworkClient& connectedClient);
|
|
||||||
void NetworkCallback(Oyster::Network::NetworkClient* client) override;
|
|
||||||
|
|
||||||
bool initiated;
|
|
||||||
bool running;
|
|
||||||
bool released;
|
|
||||||
int maxClients;
|
|
||||||
MainLobby *mainLobby;
|
|
||||||
Oyster::Network::NetworkServer *server;
|
|
||||||
static GameServer* instance;
|
|
||||||
|
|
||||||
private:
|
|
||||||
struct InitData
|
|
||||||
{
|
|
||||||
int port;
|
|
||||||
int clients;
|
|
||||||
};
|
|
||||||
bool LoadIniFile(InitData&);
|
|
||||||
|
|
||||||
private:
|
|
||||||
friend class AdminInterface;
|
|
||||||
};
|
|
||||||
}// End namspace DanBias
|
|
||||||
#endif // !DANBIASSERVER_DBSERVER_H
|
|
|
@ -1,67 +0,0 @@
|
||||||
/////////////////////////////////////////////////////////////////////
|
|
||||||
// Created by [Dennis Andersen] [2013]
|
|
||||||
/////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#include "GameClient.h"
|
|
||||||
#include "..\LobbySessions\NetworkSession.h"
|
|
||||||
#include <Protocols.h>
|
|
||||||
|
|
||||||
using namespace Utility::DynamicMemory;
|
|
||||||
using namespace DanBias;
|
|
||||||
using namespace GameLogic;
|
|
||||||
|
|
||||||
static int gameClientIDCount = 1;
|
|
||||||
|
|
||||||
GameClient::GameClient(SmartPointer<LobbyClient> client, IPlayerData* player, Oyster::Callback::OysterCallback<void, NetworkSession::NetEvent> value)
|
|
||||||
{
|
|
||||||
this->callbackValue = value;
|
|
||||||
this->client = client;
|
|
||||||
this->id = gameClientIDCount++;
|
|
||||||
this->player = player;
|
|
||||||
Oyster::Callback::OysterCallback<void, NetworkSession::NetEvent> c;
|
|
||||||
c.callbackType = Oyster::Callback::CallbackType_Object;
|
|
||||||
c.value = this;
|
|
||||||
this->client->SetCallback(c);
|
|
||||||
|
|
||||||
}
|
|
||||||
GameClient::~GameClient()
|
|
||||||
{
|
|
||||||
if(this->client) this->client->Disconnect();
|
|
||||||
this->player = 0;
|
|
||||||
this->id = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GameClient::SetCallback(Oyster::Callback::OysterCallback<void, NetworkSession::NetEvent> value)
|
|
||||||
{
|
|
||||||
this->callbackValue = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
GameLogic::IPlayerData* GameClient::GetPlayer()
|
|
||||||
{
|
|
||||||
return this->player;
|
|
||||||
}
|
|
||||||
GameLogic::IPlayerData* GameClient::ReleasePlayer()
|
|
||||||
{
|
|
||||||
GameLogic::IPlayerData *temp = this->player;
|
|
||||||
this->player = 0;
|
|
||||||
return temp;
|
|
||||||
}
|
|
||||||
LobbyClient* GameClient::GetClient() const
|
|
||||||
{
|
|
||||||
return this->client;
|
|
||||||
}
|
|
||||||
Utility::DynamicMemory::SmartPointer<LobbyClient> GameClient::ReleaseClient()
|
|
||||||
{
|
|
||||||
SmartPointer<LobbyClient> temp = this->client;
|
|
||||||
this->client = 0;
|
|
||||||
return temp;
|
|
||||||
}
|
|
||||||
int GameClient::GetID() const
|
|
||||||
{
|
|
||||||
return this->id;
|
|
||||||
}
|
|
||||||
void GameClient::ObjectCallback(NetworkSession::NetEvent e)
|
|
||||||
{
|
|
||||||
e.gameClient = this;
|
|
||||||
this->callbackValue(e);
|
|
||||||
}
|
|
|
@ -1,43 +0,0 @@
|
||||||
/////////////////////////////////////////////////////////////////////
|
|
||||||
// Created by [Dennis Andersen] [2013]
|
|
||||||
/////////////////////////////////////////////////////////////////////
|
|
||||||
#ifndef DANBIASSERVER_CLIENT_OBJECT_H
|
|
||||||
#define DANBIASSERVER_CLIENT_OBJECT_H
|
|
||||||
|
|
||||||
#include "..\LobbySessions\LobbyClient.h"
|
|
||||||
#include <PostBox\PostBox.h>
|
|
||||||
#include <GameAPI.h>
|
|
||||||
|
|
||||||
namespace DanBias
|
|
||||||
{
|
|
||||||
class GameClient: Oyster::Callback::CallbackObject<void, NetworkSession::NetEvent>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
GameClient(Utility::DynamicMemory::SmartPointer<LobbyClient> client, GameLogic::IPlayerData* player, Oyster::Callback::OysterCallback<void, NetworkSession::NetEvent> value);
|
|
||||||
virtual~GameClient();
|
|
||||||
|
|
||||||
void SetCallback(Oyster::Callback::OysterCallback<void, NetworkSession::NetEvent> value);
|
|
||||||
|
|
||||||
/* */
|
|
||||||
GameLogic::IPlayerData* GetPlayer();
|
|
||||||
|
|
||||||
GameLogic::IPlayerData* ReleasePlayer();
|
|
||||||
|
|
||||||
LobbyClient* GetClient() const;
|
|
||||||
Utility::DynamicMemory::SmartPointer<LobbyClient> ReleaseClient();
|
|
||||||
int GetID() const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
//Utility::DynamicMemory::SmartPointer<GameLogic::Player> player;
|
|
||||||
GameLogic::IPlayerData* player;
|
|
||||||
Utility::DynamicMemory::SmartPointer<LobbyClient> client;
|
|
||||||
Oyster::Callback::OysterCallback<void, NetworkSession::NetEvent> callbackValue;
|
|
||||||
int id;
|
|
||||||
void ObjectCallback(NetworkSession::NetEvent) override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
friend class AdminInterface;
|
|
||||||
};
|
|
||||||
|
|
||||||
}//End namespace DanBias
|
|
||||||
#endif // !DANBIASSERVER_CLIENT_OBJECT_H
|
|
|
@ -1,123 +0,0 @@
|
||||||
/////////////////////////////////////////////////////////////////////
|
|
||||||
// Created by [Dennis Andersen] [2013]
|
|
||||||
/////////////////////////////////////////////////////////////////////
|
|
||||||
#include "GameSessionManager.h"
|
|
||||||
|
|
||||||
#include "..\LobbySessions\LobbyClient.h"
|
|
||||||
#include "GameSession.h"
|
|
||||||
#include <DynamicArray.h>
|
|
||||||
|
|
||||||
using namespace DanBias;
|
|
||||||
using namespace Utility::DynamicMemory;
|
|
||||||
|
|
||||||
struct GameSessionData
|
|
||||||
{
|
|
||||||
DynamicArray< SmartPointer< GameSession > > sessions;
|
|
||||||
|
|
||||||
int freeSpot;
|
|
||||||
|
|
||||||
int Existst(int session)
|
|
||||||
{
|
|
||||||
for (unsigned int i = 0; i < sessions.Size(); i++)
|
|
||||||
{
|
|
||||||
if(!sessions[i] && freeSpot == -1) freeSpot = i;
|
|
||||||
if(sessions[i]->GetID() == session) return i;
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
int GetFree()
|
|
||||||
{
|
|
||||||
for (unsigned int i = 0; i < sessions.Size(); i++)
|
|
||||||
{
|
|
||||||
if(!sessions[i])
|
|
||||||
{
|
|
||||||
this->freeSpot = i;
|
|
||||||
return this->freeSpot;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this->freeSpot = -1;
|
|
||||||
return this->freeSpot;
|
|
||||||
}
|
|
||||||
|
|
||||||
} gameSessionData;
|
|
||||||
|
|
||||||
|
|
||||||
int GameSessionManager::AddSession(GameSessionDescription& instance, bool run)
|
|
||||||
{
|
|
||||||
int k = gameSessionData.GetFree();
|
|
||||||
|
|
||||||
SmartPointer<GameSession> gs = new GameSession();
|
|
||||||
|
|
||||||
DanBias::GameSession::GameDescription desc;
|
|
||||||
desc.owner = instance.exitDestionation;
|
|
||||||
desc.clients = instance.clients;
|
|
||||||
desc.mapName = instance.mapName;
|
|
||||||
|
|
||||||
|
|
||||||
if(!gs->Create(desc)) return 0;
|
|
||||||
|
|
||||||
if(k == -1) gameSessionData.sessions.Push(gs);
|
|
||||||
else gameSessionData.sessions[k] = gs;
|
|
||||||
|
|
||||||
if(run) gs->Run();
|
|
||||||
|
|
||||||
return gs->GetID();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool GameSessionManager::StartSession(int session)
|
|
||||||
{
|
|
||||||
int i = -1;
|
|
||||||
if((i = gameSessionData.Existst(session)) != -1) return false;
|
|
||||||
|
|
||||||
gameSessionData.sessions[i]->Run();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool GameSessionManager::JoinSession(int session, Utility::DynamicMemory::SmartPointer<LobbyClient> client)
|
|
||||||
{
|
|
||||||
int i = -1;
|
|
||||||
if((i = gameSessionData.Existst(session)) == -1) return false;
|
|
||||||
|
|
||||||
gameSessionData.sessions[i]->Join(client);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GameSessionManager::GetSessionInfo(int session, GameSessionInfo& data)
|
|
||||||
{
|
|
||||||
memset(&data, 0, sizeof(GameSessionInfo));
|
|
||||||
|
|
||||||
int i = -1;
|
|
||||||
if((i = gameSessionData.Existst(session)) != -1) return;
|
|
||||||
|
|
||||||
//data.gametime = gameSessionData.sessions[i]->
|
|
||||||
//data.mapName = gameSessionData.sessions[i]->
|
|
||||||
//data.numberOfPlayers = gameSessionData.sessions[i]->
|
|
||||||
}
|
|
||||||
|
|
||||||
void GameSessionManager::CloseSession()
|
|
||||||
{
|
|
||||||
for (unsigned int i = 0; i < gameSessionData.sessions.Size(); i++)
|
|
||||||
{
|
|
||||||
gameSessionData.sessions[i]->CloseSession();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void GameSessionManager::CloseSession(int session)
|
|
||||||
{
|
|
||||||
int i = -1;
|
|
||||||
if((i = gameSessionData.Existst(session)) != -1) return;
|
|
||||||
|
|
||||||
|
|
||||||
gameSessionData.sessions[i]->CloseSession();
|
|
||||||
}
|
|
||||||
|
|
||||||
int GameSessionManager::GetSessionSize()
|
|
||||||
{
|
|
||||||
return gameSessionData.sessions.Size();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,82 +0,0 @@
|
||||||
/////////////////////////////////////////////////////////////////////
|
|
||||||
// Created by [Dennis Andersen] [2013]
|
|
||||||
/////////////////////////////////////////////////////////////////////
|
|
||||||
#ifndef DANBIASSERVER_GAME_SEESION_MANAGER_H
|
|
||||||
#define DANBIASSERVER_GAME_SEESION_MANAGER_H
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <Utilities.h>
|
|
||||||
#include <DynamicArray.h>
|
|
||||||
|
|
||||||
namespace DanBias
|
|
||||||
{
|
|
||||||
class LobbyClient;
|
|
||||||
class NetworkSession;
|
|
||||||
|
|
||||||
struct GameSessionDescription
|
|
||||||
{
|
|
||||||
std::wstring mapName;
|
|
||||||
Utility::DynamicMemory::DynamicArray<Utility::DynamicMemory::SmartPointer<LobbyClient>> clients;
|
|
||||||
NetworkSession* exitDestionation; //The new owner when session dies
|
|
||||||
};
|
|
||||||
struct GameSessionInfo
|
|
||||||
{
|
|
||||||
std::wstring mapName;
|
|
||||||
unsigned int numberOfPlayers;
|
|
||||||
float gametime;
|
|
||||||
};
|
|
||||||
|
|
||||||
class GameSessionManager
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/**
|
|
||||||
* Add a new game session.
|
|
||||||
* On success, the function returns the game instance id number greater than 0.
|
|
||||||
*/
|
|
||||||
static int AddSession(GameSessionDescription& instance, bool run);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Starts an existing game session
|
|
||||||
* @param session The session id recieved when created.
|
|
||||||
* @param run Indicates if the game session should start imidiatly when created.
|
|
||||||
* @return Returns false if session is not found.
|
|
||||||
*/
|
|
||||||
static bool StartSession(int session);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Join an exiting session
|
|
||||||
* @param session The session id recieved when created.
|
|
||||||
* @param client The client that is to join a game session
|
|
||||||
* @return Returns false on failure.
|
|
||||||
*/
|
|
||||||
static bool JoinSession(int session, Utility::DynamicMemory::SmartPointer<LobbyClient> client);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets information about a given session
|
|
||||||
* @param session The session id recieved when created.
|
|
||||||
* @param sessionInformation The output parameter that will be filled.
|
|
||||||
*/
|
|
||||||
static void GetSessionInfo(int session, GameSessionInfo& sessionInformation);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Close a session.
|
|
||||||
* @param session The session id recieved when created a session.
|
|
||||||
*/
|
|
||||||
static void CloseSession(int session);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Close all sessions.
|
|
||||||
*/
|
|
||||||
static void CloseSession();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get total sessions running
|
|
||||||
* @return Returns the total sessions curently running.
|
|
||||||
*/
|
|
||||||
static int GetSessionSize();
|
|
||||||
|
|
||||||
private:
|
|
||||||
friend class AdminInterface;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
#endif // !DANBIASSERVER_GAME_SEESION_MANAGER_H
|
|
|
@ -1,29 +0,0 @@
|
||||||
/////////////////////////////////////////////////////////////////////
|
|
||||||
// Created by [Dennis Andersen] [2013]
|
|
||||||
/////////////////////////////////////////////////////////////////////
|
|
||||||
#include "GameSession.h"
|
|
||||||
#include "GameClient.h"
|
|
||||||
|
|
||||||
#include <Protocols.h>
|
|
||||||
#include <PostBox\PostBox.h>
|
|
||||||
#include <GameLogicStates.h>
|
|
||||||
#include <Windows.h>
|
|
||||||
|
|
||||||
using namespace Utility::DynamicMemory;
|
|
||||||
using namespace Oyster;
|
|
||||||
using namespace Oyster::Network;
|
|
||||||
using namespace Oyster::Thread;
|
|
||||||
using namespace GameLogic;
|
|
||||||
|
|
||||||
namespace DanBias
|
|
||||||
{
|
|
||||||
void GameSession::Send(Oyster::Network::CustomNetProtocol* p)
|
|
||||||
{
|
|
||||||
for (unsigned int i = 0; i < this->clients.Size(); i++)
|
|
||||||
{
|
|
||||||
if(this->clients[i] && this->clients[i]->GetClient())
|
|
||||||
this->clients[i]->GetClient()->Send(p);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}//End namespace DanBias
|
|
||||||
|
|
|
@ -1,30 +0,0 @@
|
||||||
/////////////////////////////////////////
|
|
||||||
// Created by [Dennis Andersen] [2013] //
|
|
||||||
/////////////////////////////////////////
|
|
||||||
#ifndef DANBIASSERVER_LEVELMANAGER_H
|
|
||||||
#define DANBIASSERVER_LEVELMANAGER_H
|
|
||||||
|
|
||||||
#include "ServerDataReader.h"
|
|
||||||
#include "..\LobbySessions\LobbyClient.h"
|
|
||||||
#include "..\LobbySessions\NetworkSession.h"
|
|
||||||
#include "..\LobbySessions\GameLobby.h"
|
|
||||||
#include <Utilities.h>
|
|
||||||
|
|
||||||
namespace DanBias
|
|
||||||
{
|
|
||||||
class MapManager
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
struct MapInitDesc
|
|
||||||
{
|
|
||||||
const wchar_t* map;
|
|
||||||
Utility::DynamicMemory::DynamicArray<Utility::DynamicMemory::SmartPointer<LobbyClient>> clients;
|
|
||||||
};
|
|
||||||
|
|
||||||
public:
|
|
||||||
static bool InitiateMapPack(const MapInitDesc& desc);
|
|
||||||
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // !DANBIASSERVER_LEVELMANAGER_H
|
|
|
@ -1,44 +0,0 @@
|
||||||
/////////////////////////////////////////////////////////////////////
|
|
||||||
// Created by [Dennis Andersen] [2013]
|
|
||||||
/////////////////////////////////////////////////////////////////////
|
|
||||||
#ifndef DANBIASSERVER_SERVER_INIT_READER_H
|
|
||||||
#define DANBIASSERVER_SERVER_INIT_READER_H
|
|
||||||
|
|
||||||
#include <fstream>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
namespace DanBias
|
|
||||||
{
|
|
||||||
enum InitPath
|
|
||||||
{
|
|
||||||
InitPath_ServerIni,
|
|
||||||
};
|
|
||||||
static std::string GetInitPath(InitPath file)
|
|
||||||
{
|
|
||||||
std::string type = "";
|
|
||||||
std::string path = "";
|
|
||||||
std::string flag = "";
|
|
||||||
|
|
||||||
switch (file)
|
|
||||||
{
|
|
||||||
case DanBias::InitPath_ServerIni:
|
|
||||||
flag = "ServerInit";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::fstream in;
|
|
||||||
in.open("..\\Settings\\serversearchpath.ini", std::ios::in);
|
|
||||||
if(!in.is_open()) return "";
|
|
||||||
|
|
||||||
while (!in.eof() && type != flag)
|
|
||||||
{
|
|
||||||
in >> type;
|
|
||||||
in >> path;
|
|
||||||
}
|
|
||||||
|
|
||||||
in.close();
|
|
||||||
return path;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // !DANBIASSERVER_SERVER_INIT_READER_H
|
|
|
@ -1,21 +0,0 @@
|
||||||
/////////////////////////////////////////////////////////////////////
|
|
||||||
// Created by [Dennis Andersen] [2013]
|
|
||||||
/////////////////////////////////////////////////////////////////////
|
|
||||||
#include "GameLobby.h"
|
|
||||||
|
|
||||||
|
|
||||||
namespace DanBias
|
|
||||||
{
|
|
||||||
GameLobby::GameLobby(Utility::DynamicMemory::SmartPointer<LobbyClient> owner)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
GameLobby::~GameLobby()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
void GameLobby::Release()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}//End namespace DanBias
|
|
|
@ -1,24 +0,0 @@
|
||||||
/////////////////////////////////////////////////////////////////////
|
|
||||||
// Created by [Dennis Andersen] [2013]
|
|
||||||
/////////////////////////////////////////////////////////////////////
|
|
||||||
#ifndef DANBIASSERVER_GAMELOBBY_H
|
|
||||||
#define DANBIASSERVER_GAMELOBBY_H
|
|
||||||
|
|
||||||
#include "NetworkSession.h"
|
|
||||||
|
|
||||||
namespace DanBias
|
|
||||||
{
|
|
||||||
class GameLobby :public NetworkSession
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
GameLobby(Utility::DynamicMemory::SmartPointer<LobbyClient> owner);
|
|
||||||
virtual~GameLobby();
|
|
||||||
|
|
||||||
void Release();
|
|
||||||
|
|
||||||
private:
|
|
||||||
friend class AdminInterface;
|
|
||||||
};
|
|
||||||
}//End namespace DanBias
|
|
||||||
|
|
||||||
#endif // !DANBIASSERVER_GAME_LOBBY_H
|
|
|
@ -1,18 +0,0 @@
|
||||||
#include "INetworkSession.h"
|
|
||||||
#include <GID.h>
|
|
||||||
|
|
||||||
INetworkSession::INetworkSession()
|
|
||||||
:id(GID())
|
|
||||||
{}
|
|
||||||
INetworkSession::INetworkSession(const INetworkSession& orig)
|
|
||||||
{
|
|
||||||
id = orig.id;
|
|
||||||
}
|
|
||||||
const INetworkSession& INetworkSession::operator=(const INetworkSession& orig)
|
|
||||||
{
|
|
||||||
id = orig.id;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
INetworkSession::~INetworkSession()
|
|
||||||
{}
|
|
||||||
|
|
|
@ -1,22 +0,0 @@
|
||||||
/////////////////////////////////////////
|
|
||||||
// Created by [Dennis Andersen] [2013] //
|
|
||||||
/////////////////////////////////////////
|
|
||||||
#ifndef DANBIASSERVER_INETWORKSESSION_H
|
|
||||||
#define DANBIASSERVER_INETWORKSESSION_H
|
|
||||||
|
|
||||||
class INetworkSession
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
INetworkSession();
|
|
||||||
INetworkSession(const INetworkSession& orig);
|
|
||||||
const INetworkSession& operator=(const INetworkSession& orig);
|
|
||||||
virtual~INetworkSession();
|
|
||||||
|
|
||||||
inline int GetID() const { return this->id; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
int id;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // !DANBIASSERVER_INETWORKSESSION_H
|
|
|
@ -1,51 +0,0 @@
|
||||||
#include "LobbyClient.h"
|
|
||||||
#include <Protocols.h>
|
|
||||||
|
|
||||||
using namespace Utility::DynamicMemory;
|
|
||||||
using namespace Oyster::Network;
|
|
||||||
using namespace Oyster::Callback;
|
|
||||||
using namespace GameLogic;
|
|
||||||
|
|
||||||
namespace DanBias
|
|
||||||
{
|
|
||||||
LobbyClient::LobbyClient(SmartPointer<NetworkClient> client)
|
|
||||||
{
|
|
||||||
this->client = client;
|
|
||||||
this->client->SetRecieverObject(this, NetworkProtocolCallbackType_Object);
|
|
||||||
}
|
|
||||||
LobbyClient::~LobbyClient()
|
|
||||||
{
|
|
||||||
this->callbackValue.callbackType = CallbackType_Unknown;
|
|
||||||
}
|
|
||||||
|
|
||||||
void LobbyClient::Disconnect()
|
|
||||||
{
|
|
||||||
this->client->Disconnect();
|
|
||||||
}
|
|
||||||
void LobbyClient::SetCallback(OysterCallback<void, NetworkSession::NetEvent> value)
|
|
||||||
{
|
|
||||||
this->callbackValue = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** This method is NOT threadsafe. */
|
|
||||||
void LobbyClient::NetworkCallback(CustomNetProtocol& protocol)
|
|
||||||
{
|
|
||||||
if(this->callbackValue.callbackType == CallbackType_Unknown) return;
|
|
||||||
|
|
||||||
NetworkSession::NetEvent e;
|
|
||||||
e.sender = this;
|
|
||||||
e.protocol = protocol;
|
|
||||||
|
|
||||||
this->callbackValue(e);
|
|
||||||
}
|
|
||||||
void LobbyClient::Disconnected()
|
|
||||||
{
|
|
||||||
if(this->callbackValue.callbackType == CallbackType_Unknown) return;
|
|
||||||
|
|
||||||
NetworkSession::NetEvent e;
|
|
||||||
e.sender = this;
|
|
||||||
e.protocol = *GameLogic::Protocol_General_Status(Protocol_General_Status::States_disconected).GetProtocol();
|
|
||||||
|
|
||||||
this->callbackValue(e);
|
|
||||||
}
|
|
||||||
}//End namsapce DanBias
|
|
|
@ -1,38 +0,0 @@
|
||||||
/////////////////////////////////////////
|
|
||||||
// Created by [Dennis Andersen] [2013] //
|
|
||||||
/////////////////////////////////////////
|
|
||||||
#ifndef DANBIASSERVER_LOBBYCLIENT_H
|
|
||||||
#define DANBIASSERVER_LOBBYCLIENT_H
|
|
||||||
|
|
||||||
#include "NetworkSession.h"
|
|
||||||
#include <NetworkClient.h>
|
|
||||||
#include <PostBox\PostBox.h>
|
|
||||||
|
|
||||||
namespace DanBias
|
|
||||||
{
|
|
||||||
class LobbyClient :public Oyster::Network::NetClientEvent
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
LobbyClient(Utility::DynamicMemory::SmartPointer<Oyster::Network::NetworkClient> client);
|
|
||||||
virtual~LobbyClient();
|
|
||||||
|
|
||||||
void Disconnect();
|
|
||||||
void SetCallback(Oyster::Callback::OysterCallback<void, NetworkSession::NetEvent> value);
|
|
||||||
|
|
||||||
inline void Send(Oyster::Network::CustomProtocolObject& protocol) { this->client->Send(protocol); }
|
|
||||||
inline void Send(Oyster::Network::CustomNetProtocol* protocol) { this->client->Send(protocol); }
|
|
||||||
inline int GetID() const { return this->client->GetID(); }
|
|
||||||
|
|
||||||
private:
|
|
||||||
Utility::DynamicMemory::SmartPointer<Oyster::Network::NetworkClient> client;
|
|
||||||
Oyster::Callback::OysterCallback<void, NetworkSession::NetEvent> callbackValue;
|
|
||||||
|
|
||||||
private:
|
|
||||||
void NetworkCallback(Oyster::Network::CustomNetProtocol& protocol) override;
|
|
||||||
void Disconnected() override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
friend class AdminInterface;
|
|
||||||
};
|
|
||||||
}//End namspace DanBias
|
|
||||||
#endif // !DANBIASSERVER_LOBBYCLIENT_H
|
|
|
@ -1,64 +0,0 @@
|
||||||
#include "MainLobby.h"
|
|
||||||
#include "LobbyClient.h"
|
|
||||||
|
|
||||||
using namespace DanBias;
|
|
||||||
using namespace GameLogic;
|
|
||||||
|
|
||||||
void MainLobby::ParseGeneralProtocol(Oyster::Network::CustomNetProtocol& p, DanBias::LobbyClient* c)
|
|
||||||
{
|
|
||||||
switch (p[0].value.netShort)
|
|
||||||
{
|
|
||||||
case protocol_General_Status:
|
|
||||||
{
|
|
||||||
GeneralStatus(GameLogic::Protocol_General_Status(p), c);
|
|
||||||
} break;
|
|
||||||
case protocol_General_Text:
|
|
||||||
{
|
|
||||||
GameLogic::Protocol_General_Text(p);
|
|
||||||
} break;
|
|
||||||
case protocol_Lobby_Login:
|
|
||||||
{
|
|
||||||
|
|
||||||
} break;
|
|
||||||
case protocol_Lobby_Join:
|
|
||||||
{
|
|
||||||
JoinLobby(GameLogic::Protocol_LobbyJoin(p), c);
|
|
||||||
} break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainLobby::GeneralStatus(GameLogic::Protocol_General_Status& p, DanBias::LobbyClient* c)
|
|
||||||
{
|
|
||||||
switch (p.status)
|
|
||||||
{
|
|
||||||
case Protocol_General_Status::States_ready:
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
case Protocol_General_Status::States_idle:
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
case Protocol_General_Status::States_leave:
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
case Protocol_General_Status::States_disconected:
|
|
||||||
{
|
|
||||||
Detach(c)->Disconnect();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainLobby::JoinLobby(GameLogic::Protocol_LobbyJoin& p, DanBias::LobbyClient* c)
|
|
||||||
{
|
|
||||||
for (unsigned int i = 0; i < this->gameLobby.Size(); i++)
|
|
||||||
{
|
|
||||||
if (this->gameLobby[i]->GetID() == p.value)
|
|
||||||
{
|
|
||||||
this->gameLobby[i]->Attach(Detach(c));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,37 +0,0 @@
|
||||||
#include "MainLobby.h"
|
|
||||||
|
|
||||||
using namespace DanBias;
|
|
||||||
|
|
||||||
void MainLobby::ParseLobbyProtocol(Oyster::Network::CustomNetProtocol& p, DanBias::LobbyClient* c)
|
|
||||||
{
|
|
||||||
switch (p[0].value.netShort)
|
|
||||||
{
|
|
||||||
case protocol_Lobby_Create:
|
|
||||||
CreateGame(GameLogic::Protocol_LobbyCreateGame(p), c);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case protocol_Lobby_Start:
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case protocol_Lobby_Refresh:
|
|
||||||
GameLogic::Protocol_LobbyRefresh();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainLobby::CreateGame(GameLogic::Protocol_LobbyCreateGame& p, DanBias::LobbyClient* c)
|
|
||||||
{
|
|
||||||
for (unsigned int i = 0; i < this->gameLobby.Size(); i++)
|
|
||||||
{
|
|
||||||
if(!gameLobby[i])
|
|
||||||
{
|
|
||||||
gameLobby[i] = new GameLobby(NetworkSession::Detach(c));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this->gameLobby.Push(new GameLobby(NetworkSession::Detach(c)));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -1,62 +0,0 @@
|
||||||
/////////////////////////////////////////////////////////////////////
|
|
||||||
// Created by [Dennis Andersen] [2013]
|
|
||||||
/////////////////////////////////////////////////////////////////////
|
|
||||||
#include "MainLobby.h"
|
|
||||||
#include "LobbyClient.h"
|
|
||||||
#include <PlayerProtocols.h>
|
|
||||||
#include <PostBox\PostBox.h>
|
|
||||||
|
|
||||||
using namespace Utility::DynamicMemory;
|
|
||||||
using namespace Oyster::Network;
|
|
||||||
using namespace Oyster;
|
|
||||||
|
|
||||||
namespace DanBias
|
|
||||||
{
|
|
||||||
MainLobby::MainLobby()
|
|
||||||
:gameLobby(5)
|
|
||||||
{
|
|
||||||
this->box = new PostBox<DanBias::NetworkSession::NetEvent>();
|
|
||||||
}
|
|
||||||
MainLobby::~MainLobby()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
void MainLobby::Release()
|
|
||||||
{
|
|
||||||
delete this->box;
|
|
||||||
this->box = 0;
|
|
||||||
this->CloseSession(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainLobby::Frame()
|
|
||||||
{
|
|
||||||
ParseEvents();
|
|
||||||
}
|
|
||||||
IPostBox<NetworkSession::NetEvent>* MainLobby::GetPostbox()
|
|
||||||
{
|
|
||||||
return this->box;
|
|
||||||
}
|
|
||||||
void MainLobby::SetRefreshFrequency(float delta)
|
|
||||||
{
|
|
||||||
this->refreshFrequency = delta;
|
|
||||||
}
|
|
||||||
|
|
||||||
float MainLobby::GetRefreshFrequency() const
|
|
||||||
{
|
|
||||||
return this->refreshFrequency;
|
|
||||||
}
|
|
||||||
//////// Private
|
|
||||||
void MainLobby::ParseEvents()
|
|
||||||
{
|
|
||||||
if(this->box && !this->box->IsEmpty())
|
|
||||||
{
|
|
||||||
NetEvent &e = this->box->Fetch();
|
|
||||||
|
|
||||||
short type = e.protocol[0].value.netShort;
|
|
||||||
|
|
||||||
if(ProtocolIsLobby(type)) ParseLobbyProtocol(e.protocol, e.sender);
|
|
||||||
else if(ProtocolIsGeneral(type)) ParseGeneralProtocol(e.protocol, e.sender);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}//End namespace DanBias
|
|
|
@ -1,49 +0,0 @@
|
||||||
/////////////////////////////////////////////////////////////////////
|
|
||||||
// Created by [Dennis Andersen] [2013]
|
|
||||||
/////////////////////////////////////////////////////////////////////
|
|
||||||
#ifndef DANBIASSERVER_MAINLOBBY_H
|
|
||||||
#define DANBIASSERVER_MAINLOBBY_H
|
|
||||||
|
|
||||||
#include "NetworkSession.h"
|
|
||||||
#include "GameLobby.h"
|
|
||||||
#include <Protocols.h>
|
|
||||||
#include <PostBox\IPostBox.h>
|
|
||||||
#include <WinTimer.h>
|
|
||||||
|
|
||||||
namespace DanBias
|
|
||||||
{
|
|
||||||
class MainLobby :public NetworkSession
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
MainLobby();
|
|
||||||
virtual~MainLobby();
|
|
||||||
void Release();
|
|
||||||
|
|
||||||
void Frame();
|
|
||||||
|
|
||||||
void SetPostbox(Oyster::IPostBox<NetworkSession::NetEvent>* box);
|
|
||||||
Oyster::IPostBox<NetworkSession::NetEvent>* GetPostbox();
|
|
||||||
|
|
||||||
void SetRefreshFrequency(float delta);
|
|
||||||
float GetRefreshFrequency() const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
void ParseEvents();
|
|
||||||
void ParseGeneralProtocol(Oyster::Network::CustomNetProtocol& p, DanBias::LobbyClient* c);
|
|
||||||
void ParseLobbyProtocol(Oyster::Network::CustomNetProtocol& p, DanBias::LobbyClient* c);
|
|
||||||
|
|
||||||
void GeneralStatus(GameLogic::Protocol_General_Status& p, DanBias::LobbyClient* c);
|
|
||||||
void CreateGame(GameLogic::Protocol_LobbyCreateGame& p, DanBias::LobbyClient* c);
|
|
||||||
void JoinLobby(GameLogic::Protocol_LobbyJoin& p, DanBias::LobbyClient* c);
|
|
||||||
|
|
||||||
private:
|
|
||||||
Oyster::IPostBox<NetworkSession::NetEvent> *box;
|
|
||||||
Utility::DynamicMemory::DynamicArray<Utility::DynamicMemory::SmartPointer<GameLobby>> gameLobby;
|
|
||||||
Utility::WinTimer timer;
|
|
||||||
float refreshFrequency;
|
|
||||||
|
|
||||||
private:
|
|
||||||
friend class AdminInterface;
|
|
||||||
};
|
|
||||||
}//End namespace DanBias
|
|
||||||
#endif // !DANBIASGAME_GAMELOBBY_H
|
|
|
@ -1,219 +0,0 @@
|
||||||
/////////////////////////////////////////////////////////////////////
|
|
||||||
// Created by [Dennis Andersen] [2013]
|
|
||||||
/////////////////////////////////////////////////////////////////////
|
|
||||||
#include "LobbyClient.h"
|
|
||||||
#include "NetworkSession.h"
|
|
||||||
#include <mutex>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace DanBias
|
|
||||||
{
|
|
||||||
NetworkSession::NetworkSession()
|
|
||||||
: owner(0)
|
|
||||||
, clientCount(0)
|
|
||||||
{}
|
|
||||||
NetworkSession::NetworkSession(const NetworkSession& orig)
|
|
||||||
{
|
|
||||||
this->clients = orig.clients;
|
|
||||||
this->owner = orig.owner;
|
|
||||||
this->clientCount = orig.clientCount;
|
|
||||||
}
|
|
||||||
const NetworkSession& NetworkSession::operator=(const NetworkSession& orig)
|
|
||||||
{
|
|
||||||
this->clients = orig.clients;
|
|
||||||
this->owner = orig.owner;
|
|
||||||
this->clientCount = orig.clientCount;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
NetworkSession::~NetworkSession()
|
|
||||||
{
|
|
||||||
this->clients.Clear();
|
|
||||||
this->clientCount = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool NetworkSession::Attach(Utility::DynamicMemory::SmartPointer<LobbyClient> client)
|
|
||||||
{
|
|
||||||
clientListLock.lock();
|
|
||||||
|
|
||||||
int k = -1;
|
|
||||||
for (unsigned int i = 0; (k == -1) && i < this->clients.Size(); i++)
|
|
||||||
{
|
|
||||||
if(!this->clients[i])
|
|
||||||
k = i;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(k == -1)
|
|
||||||
{
|
|
||||||
this->clients.Push(client);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this->clients[k] = client;
|
|
||||||
}
|
|
||||||
this->clientCount++;
|
|
||||||
clientListLock.unlock();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
Utility::DynamicMemory::SmartPointer<LobbyClient> NetworkSession::Detach(Oyster::Network::NetworkClient* client)
|
|
||||||
{
|
|
||||||
Utility::DynamicMemory::SmartPointer<LobbyClient> val;
|
|
||||||
|
|
||||||
clientListLock.lock();
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < this->clients.Size(); i++)
|
|
||||||
{
|
|
||||||
if(this->clients[0]->GetID() == client->GetID())
|
|
||||||
{
|
|
||||||
val = this->clients[i];
|
|
||||||
this->clients[i] = 0;
|
|
||||||
this->clientCount--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
clientListLock.unlock();
|
|
||||||
|
|
||||||
return val;
|
|
||||||
}
|
|
||||||
Utility::DynamicMemory::SmartPointer<LobbyClient> NetworkSession::Detach(const LobbyClient* client)
|
|
||||||
{
|
|
||||||
Utility::DynamicMemory::SmartPointer<LobbyClient> val;
|
|
||||||
|
|
||||||
clientListLock.lock();
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < this->clients.Size(); i++)
|
|
||||||
{
|
|
||||||
if(this->clients[0]->GetID() == client->GetID())
|
|
||||||
{
|
|
||||||
val = this->clients[i];
|
|
||||||
this->clients[i] = 0;
|
|
||||||
this->clientCount--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
clientListLock.unlock();
|
|
||||||
|
|
||||||
return val;
|
|
||||||
}
|
|
||||||
Utility::DynamicMemory::SmartPointer<LobbyClient> NetworkSession::Detach(const LobbyClient& client)
|
|
||||||
{
|
|
||||||
Utility::DynamicMemory::SmartPointer<LobbyClient> val;
|
|
||||||
|
|
||||||
clientListLock.lock();
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < this->clients.Size(); i++)
|
|
||||||
{
|
|
||||||
if(this->clients[0]->GetID() == client.GetID())
|
|
||||||
{
|
|
||||||
val = this->clients[i];
|
|
||||||
this->clients[i] = 0;
|
|
||||||
this->clientCount--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
clientListLock.unlock();
|
|
||||||
|
|
||||||
return val;
|
|
||||||
}
|
|
||||||
Utility::DynamicMemory::SmartPointer<LobbyClient> NetworkSession::Detach(short ID)
|
|
||||||
{
|
|
||||||
Utility::DynamicMemory::SmartPointer<LobbyClient> val;
|
|
||||||
|
|
||||||
clientListLock.lock();
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < this->clients.Size(); i++)
|
|
||||||
{
|
|
||||||
if(this->clients[0]->GetID() == ID)
|
|
||||||
{
|
|
||||||
val = this->clients[i];
|
|
||||||
this->clients[i] = 0;
|
|
||||||
this->clientCount--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
clientListLock.unlock();
|
|
||||||
|
|
||||||
return val;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool NetworkSession::Send(Oyster::Network::CustomNetProtocol& protocol)
|
|
||||||
{
|
|
||||||
bool returnValue = false;
|
|
||||||
for (unsigned int i = 0; i < this->clients.Size(); i++)
|
|
||||||
{
|
|
||||||
if(this->clients[i])
|
|
||||||
{
|
|
||||||
this->clients[i]->Send(&protocol);
|
|
||||||
returnValue = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return returnValue;
|
|
||||||
}
|
|
||||||
bool NetworkSession::Send(Oyster::Network::CustomNetProtocol& protocol, int ID)
|
|
||||||
{
|
|
||||||
for (unsigned int i = 0; i < this->clients.Size(); i++)
|
|
||||||
{
|
|
||||||
if(this->clients[i] && this->clients[i]->GetID() == ID)
|
|
||||||
{
|
|
||||||
this->clients[i]->Send(&protocol);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void NetworkSession::SetCallback(Oyster::Callback::OysterCallback<void, NetworkSession::NetEvent> value)
|
|
||||||
{
|
|
||||||
for (unsigned int i = 0; i < this->clients.Size(); i++)
|
|
||||||
{
|
|
||||||
this->clients[i]->SetCallback(value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void NetworkSession::CloseSession(bool dissconnectClients)
|
|
||||||
{
|
|
||||||
clientListLock.lock();
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < this->clients.Size(); i++)
|
|
||||||
{
|
|
||||||
if(dissconnectClients) this->clients[i]->Disconnect();
|
|
||||||
else if(this->owner) this->owner->Attach(this->clients[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
this->clients.Clear();
|
|
||||||
|
|
||||||
clientListLock.unlock();
|
|
||||||
}
|
|
||||||
Utility::DynamicMemory::SmartPointer<LobbyClient> NetworkSession::FindClient(int ID)
|
|
||||||
{
|
|
||||||
for (unsigned int i = 0; i < this->clients.Size(); i++)
|
|
||||||
{
|
|
||||||
if(this->clients[i]->GetID() == ID)
|
|
||||||
return this->clients[i];
|
|
||||||
}
|
|
||||||
return Utility::DynamicMemory::SmartPointer<LobbyClient>();
|
|
||||||
}
|
|
||||||
Utility::DynamicMemory::SmartPointer<LobbyClient> NetworkSession::FindClient(LobbyClient& obj)
|
|
||||||
{
|
|
||||||
for (unsigned int i = 0; i < this->clients.Size(); i++)
|
|
||||||
{
|
|
||||||
if(this->clients[i]->GetID() == obj.GetID())
|
|
||||||
return this->clients[i];
|
|
||||||
}
|
|
||||||
return Utility::DynamicMemory::SmartPointer<LobbyClient>();
|
|
||||||
}
|
|
||||||
Utility::DynamicMemory::SmartPointer<LobbyClient> NetworkSession::FindClient(LobbyClient* obj)
|
|
||||||
{
|
|
||||||
for (unsigned int i = 0; i < this->clients.Size(); i++)
|
|
||||||
{
|
|
||||||
if(this->clients[i]->GetID() == obj->GetID())
|
|
||||||
return this->clients[i];
|
|
||||||
}
|
|
||||||
return Utility::DynamicMemory::SmartPointer<LobbyClient>();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}//End namespace DanBias
|
|
|
@ -1,91 +0,0 @@
|
||||||
/////////////////////////////////////////////////////////////////////
|
|
||||||
// Created by [Dennis Andersen] [2013]
|
|
||||||
/////////////////////////////////////////////////////////////////////
|
|
||||||
#ifndef DANBIASSERVER_NETWORK_SESSION_H
|
|
||||||
#define DANBIASSERVER_NETWORK_SESSION_H
|
|
||||||
|
|
||||||
//warning C4150: deletion of pointer to incomplete type, no destructor called
|
|
||||||
#pragma warning(disable : 4150)
|
|
||||||
|
|
||||||
#define NOMINMAX
|
|
||||||
|
|
||||||
#include "INetworkSession.h"
|
|
||||||
#include <Utilities.h>
|
|
||||||
#include <OysterCallback.h>
|
|
||||||
#include <DynamicArray.h>
|
|
||||||
#include <PostBox\IPostBox.h>
|
|
||||||
#include <CustomNetProtocol.h>
|
|
||||||
#include <NetworkClient.h>
|
|
||||||
#include <vector>
|
|
||||||
#include <mutex>
|
|
||||||
|
|
||||||
namespace DanBias
|
|
||||||
{
|
|
||||||
class LobbyClient;
|
|
||||||
class GameClient;
|
|
||||||
|
|
||||||
class NetworkSession :public INetworkSession
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
struct NetEvent
|
|
||||||
{
|
|
||||||
LobbyClient* sender;
|
|
||||||
GameClient* gameClient;
|
|
||||||
Oyster::Network::CustomNetProtocol protocol;
|
|
||||||
NetEvent():sender(0), gameClient(0){}
|
|
||||||
};
|
|
||||||
|
|
||||||
public:
|
|
||||||
NetworkSession();
|
|
||||||
NetworkSession(const NetworkSession& orig);
|
|
||||||
const NetworkSession& operator=(const NetworkSession& orig);
|
|
||||||
virtual~NetworkSession();
|
|
||||||
|
|
||||||
virtual bool Attach(Utility::DynamicMemory::SmartPointer<LobbyClient> client);
|
|
||||||
|
|
||||||
virtual Utility::DynamicMemory::SmartPointer<LobbyClient> Detach(Oyster::Network::NetworkClient* client);
|
|
||||||
virtual Utility::DynamicMemory::SmartPointer<LobbyClient> Detach(const LobbyClient* client);
|
|
||||||
virtual Utility::DynamicMemory::SmartPointer<LobbyClient> Detach(const LobbyClient& client);
|
|
||||||
virtual Utility::DynamicMemory::SmartPointer<LobbyClient> Detach(short ID);
|
|
||||||
|
|
||||||
Utility::DynamicMemory::SmartPointer<LobbyClient> FindClient(LobbyClient& obj);
|
|
||||||
Utility::DynamicMemory::SmartPointer<LobbyClient> FindClient(LobbyClient* obj);
|
|
||||||
Utility::DynamicMemory::SmartPointer<LobbyClient> FindClient(int ID);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sends a message to all clients in this session.
|
|
||||||
*/
|
|
||||||
virtual bool Send(Oyster::Network::CustomNetProtocol& message);
|
|
||||||
/**
|
|
||||||
* Sends a message to a specific client in this session.
|
|
||||||
*/
|
|
||||||
virtual bool Send(Oyster::Network::CustomNetProtocol& protocol, int ID);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the callback to all clients to where a messages is recieved.
|
|
||||||
*/
|
|
||||||
virtual void SetCallback(Oyster::Callback::OysterCallback<void, NetworkSession::NetEvent> value);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Closes the session and sends the clients to given owner session if any.
|
|
||||||
* If session is null, clients is assumed to already be elsewhere and only releases a reference.
|
|
||||||
*/
|
|
||||||
virtual void CloseSession(bool dissconnectClients = false);
|
|
||||||
|
|
||||||
|
|
||||||
/** Set where the clients is returned on closed session. */
|
|
||||||
inline void SetOwner(NetworkSession* owner) { this->owner = owner; }
|
|
||||||
|
|
||||||
protected:
|
|
||||||
Utility::DynamicMemory::DynamicArray<Utility::DynamicMemory::SmartPointer<LobbyClient>> clients;
|
|
||||||
NetworkSession* owner; //Where clients end up when session is closed.
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::mutex clientListLock;
|
|
||||||
int clientCount;
|
|
||||||
|
|
||||||
private:
|
|
||||||
friend class AdminInterface;
|
|
||||||
};
|
|
||||||
}//End namespace DanBias
|
|
||||||
#endif // !DANBIASSERVER_NETWORK_SESSION_H
|
|
|
@ -71,7 +71,7 @@
|
||||||
<OutDir>$(SolutionDir)..\Bin\Executable\</OutDir>
|
<OutDir>$(SolutionDir)..\Bin\Executable\</OutDir>
|
||||||
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||||
<TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName>
|
<TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName>
|
||||||
<IncludePath>$(SolutionDir)Game\DanBiasServer;C:\Program Files %28x86%29\Visual Leak Detector\include;$(IncludePath)</IncludePath>
|
<IncludePath>$(SolutionDir)Game\GameServer;C:\Program Files %28x86%29\Visual Leak Detector\include;$(SolutionDir)WindowManager\;$(IncludePath)</IncludePath>
|
||||||
<LibraryPath>$(OutDir)..\DLL\;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath)</LibraryPath>
|
<LibraryPath>$(OutDir)..\DLL\;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath)</LibraryPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
@ -79,7 +79,7 @@
|
||||||
<OutDir>$(SolutionDir)..\Bin\Executable\</OutDir>
|
<OutDir>$(SolutionDir)..\Bin\Executable\</OutDir>
|
||||||
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||||
<TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName>
|
<TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName>
|
||||||
<IncludePath>$(SolutionDir)Game\DanBiasServer;C:\Program Files %28x86%29\Visual Leak Detector\include;$(IncludePath)</IncludePath>
|
<IncludePath>$(SolutionDir)Game\GameServer;C:\Program Files %28x86%29\Visual Leak Detector\include;$(SolutionDir)WindowManager\;$(IncludePath)</IncludePath>
|
||||||
<LibraryPath>$(OutDir)..\DLL\;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath)</LibraryPath>
|
<LibraryPath>$(OutDir)..\DLL\;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath)</LibraryPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
@ -87,7 +87,7 @@
|
||||||
<OutDir>$(SolutionDir)..\Bin\Executable\</OutDir>
|
<OutDir>$(SolutionDir)..\Bin\Executable\</OutDir>
|
||||||
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||||
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
|
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
|
||||||
<IncludePath>$(SolutionDir)Game\DanBiasServer;C:\Program Files %28x86%29\Visual Leak Detector\include;$(IncludePath)</IncludePath>
|
<IncludePath>$(SolutionDir)Game\GameServer;C:\Program Files %28x86%29\Visual Leak Detector\include;$(SolutionDir)WindowManager\;$(IncludePath)</IncludePath>
|
||||||
<LibraryPath>$(OutDir)..\DLL\;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath)</LibraryPath>
|
<LibraryPath>$(OutDir)..\DLL\;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath)</LibraryPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
@ -95,7 +95,7 @@
|
||||||
<OutDir>$(SolutionDir)..\Bin\Executable\</OutDir>
|
<OutDir>$(SolutionDir)..\Bin\Executable\</OutDir>
|
||||||
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||||
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
|
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
|
||||||
<IncludePath>$(SolutionDir)Game\DanBiasServer;C:\Program Files %28x86%29\Visual Leak Detector\include;$(IncludePath)</IncludePath>
|
<IncludePath>$(SolutionDir)Game\GameServer;C:\Program Files %28x86%29\Visual Leak Detector\include;$(SolutionDir)WindowManager\;$(IncludePath)</IncludePath>
|
||||||
<LibraryPath>$(OutDir)..\DLL\;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath)</LibraryPath>
|
<LibraryPath>$(OutDir)..\DLL\;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath)</LibraryPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
@ -111,8 +111,8 @@
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<DelayLoadDLLs>DanBiasGame_$(PlatformShortName)D.dll;DanBiasServer_$(PlatformShortName)D.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
<DelayLoadDLLs>DanBiasGame_$(PlatformShortName)D.dll;GameServer_$(PlatformShortName)D.dll</DelayLoadDLLs>
|
||||||
<AdditionalDependencies>DanBiasGame_$(PlatformShortName)D.lib;DanBiasServer_$(PlatformShortName)D.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>GameServer_$(PlatformShortName)D.lib;DanBiasGame_$(PlatformShortName)D.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
@ -128,8 +128,8 @@
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<DelayLoadDLLs>DanBiasServer_$(PlatformShortName)D.dll;DanBiasGame_$(PlatformShortName)D.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
<DelayLoadDLLs>DanBiasGame_$(PlatformShortName)D.dll;GameServer_$(PlatformShortName)D.dll</DelayLoadDLLs>
|
||||||
<AdditionalDependencies>DanBiasGame_$(PlatformShortName)D.lib;DanBiasServer_$(PlatformShortName)D.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>GameServer_$(PlatformShortName)D.lib;DanBiasGame_$(PlatformShortName)D.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
@ -149,8 +149,8 @@
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
<DelayLoadDLLs>DanBiasServer_$(PlatformShortName).dll;DanBiasGame_$(PlatformShortName).dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
<DelayLoadDLLs>DanBiasGame_$(PlatformShortName).dll;GameServer_$(PlatformShortName).dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
||||||
<AdditionalDependencies>DanBiasServer_$(PlatformShortName).lib;DanBiasGame_$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>GameServer_$(PlatformShortName).lib;DanBiasGame_$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
@ -170,13 +170,18 @@
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
<DelayLoadDLLs>DanBiasServer_$(PlatformShortName).dll;DanBiasGame_$(PlatformShortName).dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
<DelayLoadDLLs>DanBiasGame_$(PlatformShortName).dll;GameServer_$(PlatformShortName).dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
||||||
<AdditionalDependencies>DanBiasServer_$(PlatformShortName).lib;DanBiasGame_$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>GameServer_$(PlatformShortName).lib;DanBiasGame_$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="ServerLauncher.cpp" />
|
<ClCompile Include="ServerLauncher.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\..\WindowManager\WindowManager.vcxproj">
|
||||||
|
<Project>{35aea3c0-e0a7-4e1e-88cd-514aa5a442b1}</Project>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
<ImportGroup Label="ExtensionTargets">
|
<ImportGroup Label="ExtensionTargets">
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
|
|
|
@ -5,9 +5,10 @@
|
||||||
#define NOMINMAX //Blame it on windows
|
#define NOMINMAX //Blame it on windows
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#include <vld.h>
|
#include <vld.h>
|
||||||
|
#include <iostream>
|
||||||
|
#include <WindowShell.h>
|
||||||
|
|
||||||
|
#include <GameServerAPI.h>
|
||||||
#include <DanBiasServerAPI.h>
|
|
||||||
|
|
||||||
int WINAPI WinMain( HINSTANCE hinst, HINSTANCE prevInst, PSTR cmdLine, int cmdShow)
|
int WINAPI WinMain( HINSTANCE hinst, HINSTANCE prevInst, PSTR cmdLine, int cmdShow)
|
||||||
{
|
{
|
||||||
|
@ -15,10 +16,15 @@ int WINAPI WinMain( HINSTANCE hinst, HINSTANCE prevInst, PSTR cmdLine, int cmdSh
|
||||||
{
|
{
|
||||||
return cmdShow;
|
return cmdShow;
|
||||||
}
|
}
|
||||||
if( DanBias::DanBiasServerAPI::Initiate() == DanBias::DanBiasServerReturn_Sucess)
|
|
||||||
|
WindowShell::CreateConsoleWindow();
|
||||||
|
|
||||||
|
DanBias::GameServerAPI::GameInitDesc desc;
|
||||||
|
desc.listenPort = 15151;
|
||||||
|
if(DanBias::GameServerAPI::Create(desc) == DanBias::DanBiasServerReturn_Sucess)
|
||||||
{
|
{
|
||||||
DanBias::DanBiasServerAPI::Run();
|
DanBias::GameServerAPI::Start();
|
||||||
DanBias::DanBiasServerAPI::Release();
|
DanBias::GameServerAPI::Terminate();
|
||||||
}
|
}
|
||||||
return cmdShow;
|
return cmdShow;
|
||||||
}
|
}
|
|
@ -20,7 +20,7 @@ using namespace GameLogic;
|
||||||
Player *player = ((Game::PlayerData*)(rigidBodyPlayer->GetCustomTag()))->player;
|
Player *player = ((Game::PlayerData*)(rigidBodyPlayer->GetCustomTag()))->player;
|
||||||
Object *realObj = (Object*)obj->GetCustomTag(); //needs to be changed?
|
Object *realObj = (Object*)obj->GetCustomTag(); //needs to be changed?
|
||||||
|
|
||||||
switch (realObj->GetType())
|
switch (realObj->GetObjectType())
|
||||||
{
|
{
|
||||||
case OBJECT_TYPE::OBJECT_TYPE_GENERIC:
|
case OBJECT_TYPE::OBJECT_TYPE_GENERIC:
|
||||||
PlayerVObject(*player,*realObj, kineticEnergyLoss);
|
PlayerVObject(*player,*realObj, kineticEnergyLoss);
|
||||||
|
|
|
@ -32,14 +32,15 @@ namespace GameLogic
|
||||||
~PlayerData();
|
~PlayerData();
|
||||||
|
|
||||||
void Move(const PLAYER_MOVEMENT &movement) override;
|
void Move(const PLAYER_MOVEMENT &movement) override;
|
||||||
void Rotate(const Oyster::Math3D::Float3 lookDir) override;
|
|
||||||
void UseWeapon(const WEAPON_FIRE &usage) override;
|
void UseWeapon(const WEAPON_FIRE &usage) override;
|
||||||
int GetTeamID() const override;
|
int GetTeamID() const override;
|
||||||
PLAYER_STATE GetState() const override;
|
PLAYER_STATE GetState() const override;
|
||||||
Oyster::Math::Float3 GetPosition() override;
|
Oyster::Math::Float3 GetPosition() override;
|
||||||
Oyster::Math::Float4x4 GetOrientation() override;
|
Oyster::Math::Float4x4 GetOrientation() override;
|
||||||
int GetID() const override;
|
int GetID() const override;
|
||||||
OBJECT_TYPE GetType() const override;
|
OBJECT_TYPE GetObjectType() const override;
|
||||||
|
void Rotate(const Oyster::Math3D::Float3 lookDir) override;
|
||||||
|
|
||||||
Player *player;
|
Player *player;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -51,9 +52,8 @@ namespace GameLogic
|
||||||
Oyster::Math::Float3 GetPosition() override;
|
Oyster::Math::Float3 GetPosition() override;
|
||||||
Oyster::Math::Float4x4 GetOrientation() override;
|
Oyster::Math::Float4x4 GetOrientation() override;
|
||||||
int GetID() const override;
|
int GetID() const override;
|
||||||
OBJECT_TYPE GetType() const override;
|
OBJECT_TYPE GetObjectType() const override;
|
||||||
IObjectData* GetObjectAt(int ID) const override;
|
IObjectData* GetObjectAt(int ID) const override;
|
||||||
|
|
||||||
Level *level;
|
Level *level;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#include "GameLogicStates.h"
|
#include "GameLogicStates.h"
|
||||||
#include <OysterMath.h>
|
#include <OysterMath.h>
|
||||||
|
|
||||||
|
|
||||||
namespace GameLogic
|
namespace GameLogic
|
||||||
{
|
{
|
||||||
class IObjectData;
|
class IObjectData;
|
||||||
|
@ -61,7 +62,7 @@ namespace GameLogic
|
||||||
/** Get the type of the object
|
/** Get the type of the object
|
||||||
* @return The OBJECT_TYPE of the object is returned
|
* @return The OBJECT_TYPE of the object is returned
|
||||||
*/
|
*/
|
||||||
virtual OBJECT_TYPE GetType() const = 0;
|
virtual OBJECT_TYPE GetObjectType() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class IPlayerData :public IObjectData
|
class IPlayerData :public IObjectData
|
||||||
|
@ -78,7 +79,7 @@ namespace GameLogic
|
||||||
* @param x: The relative x axis
|
* @param x: The relative x axis
|
||||||
* @param y: The relative y axis
|
* @param y: The relative y axis
|
||||||
**/
|
**/
|
||||||
virtual void Rotate(const const Oyster::Math3D::Float3 lookDir) = 0;
|
virtual void Rotate(const Oyster::Math3D::Float3 lookDir) = 0;
|
||||||
|
|
||||||
/********************************************************
|
/********************************************************
|
||||||
* Uses the chosen players weapon based on input
|
* Uses the chosen players weapon based on input
|
||||||
|
@ -100,7 +101,6 @@ namespace GameLogic
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual IObjectData* GetObjectAt(int ID) const = 0;
|
virtual IObjectData* GetObjectAt(int ID) const = 0;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class DANBIAS_GAMELOGIC_DLL GameAPI
|
class DANBIAS_GAMELOGIC_DLL GameAPI
|
||||||
|
|
|
@ -30,9 +30,9 @@ int Game::LevelData::GetID() const
|
||||||
{
|
{
|
||||||
return ((IObjectData*)this->level)->GetID();
|
return ((IObjectData*)this->level)->GetID();
|
||||||
}
|
}
|
||||||
OBJECT_TYPE Game::LevelData::GetType() const
|
OBJECT_TYPE Game::LevelData::GetObjectType() const
|
||||||
{
|
{
|
||||||
return ((IObjectData*)this->level)->GetType();
|
return ((IObjectData*)this->level)->GetObjectType();
|
||||||
//return OBJECT_TYPE_UNKNOWN;
|
//return OBJECT_TYPE_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,9 +55,9 @@ int Game::PlayerData::GetTeamID() const
|
||||||
return this->player->GetTeamID();
|
return this->player->GetTeamID();
|
||||||
}
|
}
|
||||||
|
|
||||||
OBJECT_TYPE Game::PlayerData::GetType() const
|
OBJECT_TYPE Game::PlayerData::GetObjectType() const
|
||||||
{
|
{
|
||||||
return this->player->GetType();
|
return this->player->GetObjectType();
|
||||||
}
|
}
|
||||||
void Game::PlayerData::Rotate(const Oyster::Math3D::Float3 lookDir)
|
void Game::PlayerData::Rotate(const Oyster::Math3D::Float3 lookDir)
|
||||||
{
|
{
|
||||||
|
|
|
@ -101,7 +101,7 @@ Object::~Object(void)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
OBJECT_TYPE Object::GetType() const
|
OBJECT_TYPE Object::GetObjectType() const
|
||||||
{
|
{
|
||||||
return this->type;
|
return this->type;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ namespace GameLogic
|
||||||
~Object(void);
|
~Object(void);
|
||||||
|
|
||||||
// API overrides
|
// API overrides
|
||||||
OBJECT_TYPE GetType() const;
|
OBJECT_TYPE GetObjectType() const;
|
||||||
int GetID() const;
|
int GetID() const;
|
||||||
Oyster::Math::Float3 GetPosition();
|
Oyster::Math::Float3 GetPosition();
|
||||||
Oyster::Math::Float4x4 GetOrientation();
|
Oyster::Math::Float4x4 GetOrientation();
|
||||||
|
|
|
@ -155,7 +155,6 @@
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="GeneralProtocols.h" />
|
<ClInclude Include="GeneralProtocols.h" />
|
||||||
<ClInclude Include="GameplayProtocols.h" />
|
|
||||||
<ClInclude Include="Protocols.h" />
|
<ClInclude Include="Protocols.h" />
|
||||||
<ClInclude Include="LobbyProtocols.h" />
|
<ClInclude Include="LobbyProtocols.h" />
|
||||||
<ClInclude Include="ObjectProtocols.h" />
|
<ClInclude Include="ObjectProtocols.h" />
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
#ifndef GAMEPROTOCOLS_GAMEPLAYPROTOCOLS_H
|
|
||||||
#define GAMEPROTOCOLS_GAMEPLAYPROTOCOLS_H
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include <CustomNetProtocol.h>
|
|
||||||
#include "ProtocolIdentificationID.h"
|
|
||||||
|
|
||||||
namespace GameLogic
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // !GAMEPROTOCOLS_GAMEPLAYPROTOCOLS_H
|
|
|
@ -45,14 +45,18 @@ namespace GameLogic
|
||||||
|
|
||||||
struct Protocol_LobbyStartGame :public Oyster::Network::CustomProtocolObject
|
struct Protocol_LobbyStartGame :public Oyster::Network::CustomProtocolObject
|
||||||
{
|
{
|
||||||
char gameId;
|
short gameId;
|
||||||
|
|
||||||
Protocol_LobbyStartGame()
|
Protocol_LobbyStartGame()
|
||||||
{
|
{
|
||||||
this->protocol[protocol_INDEX_ID].value = protocol_Lobby_Start;
|
this->protocol[protocol_INDEX_ID].value = protocol_Lobby_Start;
|
||||||
this->protocol[protocol_INDEX_ID].type = Oyster::Network::NetAttributeType_Short;
|
this->protocol[protocol_INDEX_ID].type = Oyster::Network::NetAttributeType_Short;
|
||||||
|
|
||||||
this->protocol[1].type = Oyster::Network::NetAttributeType_Char;
|
this->protocol[1].type = Oyster::Network::NetAttributeType_Short;
|
||||||
|
}
|
||||||
|
Protocol_LobbyStartGame(Oyster::Network::CustomNetProtocol& o)
|
||||||
|
{
|
||||||
|
gameId = o[1].value.netInt;
|
||||||
}
|
}
|
||||||
Oyster::Network::CustomNetProtocol* GetProtocol() override
|
Oyster::Network::CustomNetProtocol* GetProtocol() override
|
||||||
{
|
{
|
||||||
|
@ -73,6 +77,10 @@ namespace GameLogic
|
||||||
this->protocol[protocol_INDEX_ID].type = Oyster::Network::NetAttributeType_Short;
|
this->protocol[protocol_INDEX_ID].type = Oyster::Network::NetAttributeType_Short;
|
||||||
|
|
||||||
this->protocol[1].type = Oyster::Network::NetAttributeType_Short;
|
this->protocol[1].type = Oyster::Network::NetAttributeType_Short;
|
||||||
|
}
|
||||||
|
Protocol_LobbyLogin(Oyster::Network::CustomNetProtocol& p)
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
Oyster::Network::CustomNetProtocol* GetProtocol() override
|
Oyster::Network::CustomNetProtocol* GetProtocol() override
|
||||||
{
|
{
|
||||||
|
@ -116,6 +124,10 @@ namespace GameLogic
|
||||||
{
|
{
|
||||||
this->protocol[protocol_INDEX_ID].value = protocol_Lobby_Login;
|
this->protocol[protocol_INDEX_ID].value = protocol_Lobby_Login;
|
||||||
this->protocol[protocol_INDEX_ID].type = Oyster::Network::NetAttributeType_Short;
|
this->protocol[protocol_INDEX_ID].type = Oyster::Network::NetAttributeType_Short;
|
||||||
|
}
|
||||||
|
Protocol_LobbyRefresh(Oyster::Network::CustomNetProtocol& o)
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
Oyster::Network::CustomNetProtocol* GetProtocol() override
|
Oyster::Network::CustomNetProtocol* GetProtocol() override
|
||||||
{ return &protocol; }
|
{ return &protocol; }
|
||||||
|
@ -144,6 +156,13 @@ namespace GameLogic
|
||||||
|
|
||||||
list.Reserve(10);
|
list.Reserve(10);
|
||||||
}
|
}
|
||||||
|
Protocol_LobbyGameData(Oyster::Network::CustomNetProtocol& p)
|
||||||
|
{
|
||||||
|
this->protocol[protocol_INDEX_ID].value = protocol_Lobby_GameData;
|
||||||
|
this->protocol[protocol_INDEX_ID].type = Oyster::Network::NetAttributeType_Short;
|
||||||
|
|
||||||
|
list.Reserve(10);
|
||||||
|
}
|
||||||
Oyster::Network::CustomNetProtocol* GetProtocol() override
|
Oyster::Network::CustomNetProtocol* GetProtocol() override
|
||||||
{
|
{
|
||||||
int a = 1;
|
int a = 1;
|
||||||
|
@ -174,6 +193,10 @@ namespace GameLogic
|
||||||
this->protocol[protocol_INDEX_ID].type = Oyster::Network::NetAttributeType_Short;
|
this->protocol[protocol_INDEX_ID].type = Oyster::Network::NetAttributeType_Short;
|
||||||
|
|
||||||
this->protocol[1].type = Oyster::Network::NetAttributeType_Short;
|
this->protocol[1].type = Oyster::Network::NetAttributeType_Short;
|
||||||
|
}
|
||||||
|
Protocol_LobbyMainData(Oyster::Network::CustomNetProtocol& p)
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
Oyster::Network::CustomNetProtocol* GetProtocol() override
|
Oyster::Network::CustomNetProtocol* GetProtocol() override
|
||||||
{
|
{
|
||||||
|
|
|
@ -21,6 +21,10 @@ namespace GameLogic
|
||||||
|
|
||||||
object_ID = -1;
|
object_ID = -1;
|
||||||
pickup_ID = -1;
|
pickup_ID = -1;
|
||||||
|
}
|
||||||
|
Protocol_ObjectPickup(Oyster::Network::CustomNetProtocol& p)
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
Protocol_ObjectPickup(int objectID, short pickupID)
|
Protocol_ObjectPickup(int objectID, short pickupID)
|
||||||
{
|
{
|
||||||
|
@ -60,6 +64,10 @@ namespace GameLogic
|
||||||
|
|
||||||
object_ID = -1;
|
object_ID = -1;
|
||||||
health = 0.0f;
|
health = 0.0f;
|
||||||
|
}
|
||||||
|
Protocol_ObjectDamage(Oyster::Network::CustomNetProtocol& p)
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
Protocol_ObjectDamage(int id, float hp)
|
Protocol_ObjectDamage(int id, float hp)
|
||||||
{
|
{
|
||||||
|
@ -100,6 +108,10 @@ namespace GameLogic
|
||||||
}
|
}
|
||||||
object_ID = -1;
|
object_ID = -1;
|
||||||
memset(&worldMatrix[0], 0, sizeof(float) * 16);
|
memset(&worldMatrix[0], 0, sizeof(float) * 16);
|
||||||
|
}
|
||||||
|
Protocol_ObjectPosition(Oyster::Network::CustomNetProtocol& p)
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
Protocol_ObjectPosition(float m[16], int id)
|
Protocol_ObjectPosition(float m[16], int id)
|
||||||
{
|
{
|
||||||
|
@ -148,6 +160,10 @@ namespace GameLogic
|
||||||
}
|
}
|
||||||
object_ID = -1;
|
object_ID = -1;
|
||||||
memset(&worldMatrix[0], 0, sizeof(float) * 16);
|
memset(&worldMatrix[0], 0, sizeof(float) * 16);
|
||||||
|
}
|
||||||
|
Protocol_ObjectEnable(Oyster::Network::CustomNetProtocol& p)
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
Protocol_ObjectEnable(float m[16], int id)
|
Protocol_ObjectEnable(float m[16], int id)
|
||||||
{
|
{
|
||||||
|
@ -188,6 +204,10 @@ namespace GameLogic
|
||||||
|
|
||||||
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
|
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
|
||||||
this->protocol[2].type = Oyster::Network::NetAttributeType_Float;
|
this->protocol[2].type = Oyster::Network::NetAttributeType_Float;
|
||||||
|
}
|
||||||
|
Protocol_ObjectDisable(Oyster::Network::CustomNetProtocol& p)
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
Protocol_ObjectDisable(int id, float time)
|
Protocol_ObjectDisable(int id, float time)
|
||||||
{
|
{
|
||||||
|
@ -229,6 +249,10 @@ namespace GameLogic
|
||||||
{
|
{
|
||||||
this->protocol[i].type = Oyster::Network::NetAttributeType_Float;
|
this->protocol[i].type = Oyster::Network::NetAttributeType_Float;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
Protocol_ObjectCreate(Oyster::Network::CustomNetProtocol& p)
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
Protocol_ObjectCreate(float m[16], int id, char *path)
|
Protocol_ObjectCreate(float m[16], int id, char *path)
|
||||||
{
|
{
|
||||||
|
|
|
@ -32,6 +32,10 @@ namespace GameLogic
|
||||||
this->protocol[2].type = Oyster::Network::NetAttributeType_Bool;
|
this->protocol[2].type = Oyster::Network::NetAttributeType_Bool;
|
||||||
this->protocol[3].type = Oyster::Network::NetAttributeType_Bool;
|
this->protocol[3].type = Oyster::Network::NetAttributeType_Bool;
|
||||||
this->protocol[4].type = Oyster::Network::NetAttributeType_Bool;
|
this->protocol[4].type = Oyster::Network::NetAttributeType_Bool;
|
||||||
|
}
|
||||||
|
Protocol_PlayerMovement(Oyster::Network::CustomNetProtocol& p)
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
const Protocol_PlayerMovement& operator=(Oyster::Network::CustomNetProtocol& val)
|
const Protocol_PlayerMovement& operator=(Oyster::Network::CustomNetProtocol& val)
|
||||||
{
|
{
|
||||||
|
@ -72,6 +76,10 @@ namespace GameLogic
|
||||||
this->protocol[2].type = Oyster::Network::NetAttributeType_Float;
|
this->protocol[2].type = Oyster::Network::NetAttributeType_Float;
|
||||||
this->protocol[3].type = Oyster::Network::NetAttributeType_Float;
|
this->protocol[3].type = Oyster::Network::NetAttributeType_Float;
|
||||||
|
|
||||||
|
}
|
||||||
|
Protocol_PlayerLook(Oyster::Network::CustomNetProtocol& p)
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
const Protocol_PlayerLook& operator=(Oyster::Network::CustomNetProtocol& val)
|
const Protocol_PlayerLook& operator=(Oyster::Network::CustomNetProtocol& val)
|
||||||
{
|
{
|
||||||
|
@ -108,6 +116,10 @@ namespace GameLogic
|
||||||
this->protocol[2].type = Oyster::Network::NetAttributeType_Float;
|
this->protocol[2].type = Oyster::Network::NetAttributeType_Float;
|
||||||
this->protocol[3].type = Oyster::Network::NetAttributeType_Float;
|
this->protocol[3].type = Oyster::Network::NetAttributeType_Float;
|
||||||
|
|
||||||
|
}
|
||||||
|
Protocol_PlayerChangeWeapon(Oyster::Network::CustomNetProtocol& p)
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
const Protocol_PlayerChangeWeapon& operator=(Oyster::Network::CustomNetProtocol& val)
|
const Protocol_PlayerChangeWeapon& operator=(Oyster::Network::CustomNetProtocol& val)
|
||||||
{
|
{
|
||||||
|
@ -132,6 +144,10 @@ namespace GameLogic
|
||||||
this->protocol[protocol_INDEX_ID].type = Oyster::Network::NetAttributeType_Short;
|
this->protocol[protocol_INDEX_ID].type = Oyster::Network::NetAttributeType_Short;
|
||||||
|
|
||||||
this->protocol[1].type = Oyster::Network::NetAttributeType_Bool;
|
this->protocol[1].type = Oyster::Network::NetAttributeType_Bool;
|
||||||
|
}
|
||||||
|
Protocol_PlayerShot(Oyster::Network::CustomNetProtocol& p)
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
const Protocol_PlayerShot& operator=(Oyster::Network::CustomNetProtocol& val)
|
const Protocol_PlayerShot& operator=(Oyster::Network::CustomNetProtocol& val)
|
||||||
{
|
{
|
||||||
|
@ -158,6 +174,10 @@ namespace GameLogic
|
||||||
this->protocol[protocol_INDEX_ID].type = Oyster::Network::NetAttributeType_Short;
|
this->protocol[protocol_INDEX_ID].type = Oyster::Network::NetAttributeType_Short;
|
||||||
|
|
||||||
this->protocol[1].type = Oyster::Network::NetAttributeType_Bool;
|
this->protocol[1].type = Oyster::Network::NetAttributeType_Bool;
|
||||||
|
}
|
||||||
|
Protocol_PlayerJump(Oyster::Network::CustomNetProtocol& p)
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
const Protocol_PlayerJump& operator=(Oyster::Network::CustomNetProtocol& val)
|
const Protocol_PlayerJump& operator=(Oyster::Network::CustomNetProtocol& val)
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,6 +5,5 @@
|
||||||
#include "PlayerProtocols.h"
|
#include "PlayerProtocols.h"
|
||||||
#include "LobbyProtocols.h"
|
#include "LobbyProtocols.h"
|
||||||
#include "GeneralProtocols.h"
|
#include "GeneralProtocols.h"
|
||||||
#include "GameplayProtocols.h"
|
|
||||||
|
|
||||||
#endif // !GAMEPROTOCOLS_GAMEPROTOCOLS_H
|
#endif // !GAMEPROTOCOLS_GAMEPROTOCOLS_H
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
/////////////////////////////////////////////////////////////////////
|
||||||
|
// Created by [Dennis Andersen] [2013]
|
||||||
|
/////////////////////////////////////////////////////////////////////
|
||||||
|
#ifndef DANBIASSERVER_CLIENT_OBJECT_H
|
||||||
|
#define DANBIASSERVER_CLIENT_OBJECT_H
|
||||||
|
|
||||||
|
#include <NetworkClient.h>
|
||||||
|
#include <PostBox\PostBox.h>
|
||||||
|
#include <GameAPI.h>
|
||||||
|
#include <Utilities.h>
|
||||||
|
|
||||||
|
namespace DanBias
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Container to keep logic player and network client together as a unit.
|
||||||
|
*/
|
||||||
|
class GameClient
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
GameClient(Utility::DynamicMemory::SmartPointer<Oyster::Network::NetworkClient> client, GameLogic::IPlayerData* player);
|
||||||
|
virtual~GameClient();
|
||||||
|
|
||||||
|
GameLogic::IPlayerData* GetPlayer();
|
||||||
|
GameLogic::IPlayerData* ReleasePlayer();
|
||||||
|
Utility::DynamicMemory::SmartPointer<Oyster::Network::NetworkClient> GetClient();
|
||||||
|
Utility::DynamicMemory::SmartPointer<Oyster::Network::NetworkClient> ReleaseClient();
|
||||||
|
int GetID() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
GameLogic::IPlayerData* player;
|
||||||
|
Utility::DynamicMemory::SmartPointer<Oyster::Network::NetworkClient> client;
|
||||||
|
int id;
|
||||||
|
};
|
||||||
|
|
||||||
|
}//End namespace DanBias
|
||||||
|
#endif // !DANBIASSERVER_CLIENT_OBJECT_H
|
|
@ -0,0 +1,48 @@
|
||||||
|
/////////////////////////////////////////////////////////////////////
|
||||||
|
// Created by [Dennis Andersen] [2013]
|
||||||
|
/////////////////////////////////////////////////////////////////////
|
||||||
|
#ifndef DANBIASSERVER_MAINLOBBY_H
|
||||||
|
#define DANBIASSERVER_MAINLOBBY_H
|
||||||
|
|
||||||
|
#include <NetworkSession.h>
|
||||||
|
#include <Protocols.h>
|
||||||
|
#include <PostBox\IPostBox.h>
|
||||||
|
#include <WinTimer.h>
|
||||||
|
#include "GameSession.h"
|
||||||
|
|
||||||
|
namespace DanBias
|
||||||
|
{
|
||||||
|
class GameLobby :public Oyster::Network::NetworkSession
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
GameLobby();
|
||||||
|
virtual~GameLobby();
|
||||||
|
void Release();
|
||||||
|
void Update();
|
||||||
|
|
||||||
|
operator bool();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void ParseProtocol(Oyster::Network::CustomNetProtocol& p, Oyster::Network::NetworkClient* c);
|
||||||
|
|
||||||
|
void GeneralStatus(GameLogic::Protocol_General_Status& p, Oyster::Network::NetworkClient* c); //id = protocol_General_Status:
|
||||||
|
void GeneralText(GameLogic::Protocol_General_Text& p, Oyster::Network::NetworkClient* c); //id = protocol_General_Text:
|
||||||
|
void LobbyCreateGame(GameLogic::Protocol_LobbyCreateGame& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_Create:
|
||||||
|
void LobbyStartGame(GameLogic::Protocol_LobbyStartGame& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_Start:
|
||||||
|
void LobbyJoin(GameLogic::Protocol_LobbyJoin& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_Join:
|
||||||
|
void LobbyLogin(GameLogic::Protocol_LobbyLogin& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_Login:
|
||||||
|
void LobbyRefresh(GameLogic::Protocol_LobbyRefresh& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_Refresh:
|
||||||
|
void LobbyMainData(GameLogic::Protocol_LobbyMainData& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_MainData:
|
||||||
|
void LobbyGameData(GameLogic::Protocol_LobbyGameData& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_GameData:
|
||||||
|
|
||||||
|
private:
|
||||||
|
void ClientEventCallback(Oyster::Network::NetEvent<Oyster::Network::NetworkClient*, Oyster::Network::NetworkClient::ClientEventArgs> e) override;
|
||||||
|
void ClientConnectedEvent(Utility::DynamicMemory::SmartPointer<Oyster::Network::NetworkClient> client) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
Utility::WinTimer timer;
|
||||||
|
float refreshFrequency;
|
||||||
|
GameSession* gameSession;
|
||||||
|
};
|
||||||
|
}//End namespace DanBias
|
||||||
|
#endif // !DANBIASGAME_GAMELOBBY_H
|
|
@ -19,9 +19,10 @@
|
||||||
</ProjectConfiguration>
|
</ProjectConfiguration>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<PropertyGroup Label="Globals">
|
<PropertyGroup Label="Globals">
|
||||||
<ProjectGuid>{52380DAA-0F4A-4D97-8E57-98DF39319CAF}</ProjectGuid>
|
<ProjectGuid>{143BD516-20A1-4890-A3E4-F8BFD02220E7}</ProjectGuid>
|
||||||
<Keyword>Win32Proj</Keyword>
|
<Keyword>Win32Proj</Keyword>
|
||||||
<RootNamespace>DanBiasServer</RootNamespace>
|
<RootNamespace>GameServer</RootNamespace>
|
||||||
|
<ProjectName>GameServer</ProjectName>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
|
@ -73,32 +74,32 @@
|
||||||
<OutDir>$(SolutionDir)..\Bin\DLL\</OutDir>
|
<OutDir>$(SolutionDir)..\Bin\DLL\</OutDir>
|
||||||
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||||
<TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName>
|
<TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName>
|
||||||
<IncludePath>$(SolutionDir)..\External\Include\;$(SolutionDir)Game\GameProtocols\;$(SolutionDir)Game\GameLogic\;$(SolutionDir)Network\NetworkAPI\;$(SolutionDir)OysterMath\;$(SolutionDir)GamePhysics\;$(SolutionDir)Misc\;$(SolutionDir)WindowManager\;C:\Program Files %28x86%29\Visual Leak Detector\include;$(SolutionDir)OysterPhysics3D\;$(IncludePath)</IncludePath>
|
<IncludePath>$(SolutionDir)..\External\Include\;$(SolutionDir)Game\GameProtocols\;$(SolutionDir)Game\GameLogic\;$(SolutionDir)Network\NetworkAPI\;$(SolutionDir)OysterMath\;$(SolutionDir)GamePhysics\;$(SolutionDir)Misc\;$(SolutionDir)WindowManager\;$(SolutionDir)OysterPhysics3D\;$(SolutionDir)Game\ServerDependencies;C:\Program Files %28x86%29\Visual Leak Detector\include;$(IncludePath)</IncludePath>
|
||||||
<LibraryPath>$(OutDir);$(SolutionDir)..\External\Lib\WindowManager\;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath)</LibraryPath>
|
<LibraryPath>$(OutDir);$(SolutionDir)..\External\Lib\WindowManager\;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(SolutionDir)..\External\Lib\ServerDependencies\;$(LibraryPath)</LibraryPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
<LinkIncremental>true</LinkIncremental>
|
<LinkIncremental>true</LinkIncremental>
|
||||||
<OutDir>$(SolutionDir)..\Bin\DLL\</OutDir>
|
<OutDir>$(SolutionDir)..\Bin\DLL\</OutDir>
|
||||||
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||||
<TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName>
|
<TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName>
|
||||||
<IncludePath>$(SolutionDir)..\External\Include\;$(SolutionDir)Game\GameProtocols\;$(SolutionDir)Game\GameLogic\;$(SolutionDir)Network\NetworkAPI\;$(SolutionDir)OysterMath\;$(SolutionDir)GamePhysics\;$(SolutionDir)Misc\;$(SolutionDir)WindowManager\;C:\Program Files %28x86%29\Visual Leak Detector\include;$(SolutionDir)OysterPhysics3D\;$(IncludePath)</IncludePath>
|
<IncludePath>$(SolutionDir)..\External\Include\;$(SolutionDir)Game\GameProtocols\;$(SolutionDir)Game\GameLogic\;$(SolutionDir)Network\NetworkAPI\;$(SolutionDir)OysterMath\;$(SolutionDir)GamePhysics\;$(SolutionDir)Misc\;$(SolutionDir)WindowManager\;$(SolutionDir)OysterPhysics3D\;$(SolutionDir)Game\ServerDependencies;C:\Program Files %28x86%29\Visual Leak Detector\include;$(IncludePath)</IncludePath>
|
||||||
<LibraryPath>$(OutDir);$(SolutionDir)..\External\Lib\WindowManager\;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath)</LibraryPath>
|
<LibraryPath>$(OutDir);$(SolutionDir)..\External\Lib\WindowManager\;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(SolutionDir)..\External\Lib\ServerDependencies\;$(LibraryPath)</LibraryPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
<LinkIncremental>false</LinkIncremental>
|
<LinkIncremental>false</LinkIncremental>
|
||||||
<OutDir>$(SolutionDir)..\Bin\DLL\</OutDir>
|
<OutDir>$(SolutionDir)..\Bin\DLL\</OutDir>
|
||||||
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||||
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
|
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
|
||||||
<IncludePath>$(SolutionDir)..\External\Include\;$(SolutionDir)Game\GameProtocols\;$(SolutionDir)Game\GameLogic\;$(SolutionDir)Network\NetworkAPI\;$(SolutionDir)OysterMath\;$(SolutionDir)GamePhysics\;$(SolutionDir)Misc\;$(SolutionDir)WindowManager\;C:\Program Files %28x86%29\Visual Leak Detector\include;$(SolutionDir)OysterPhysics3D\;$(IncludePath)</IncludePath>
|
<IncludePath>$(SolutionDir)..\External\Include\;$(SolutionDir)Game\GameProtocols\;$(SolutionDir)Game\GameLogic\;$(SolutionDir)Network\NetworkAPI\;$(SolutionDir)OysterMath\;$(SolutionDir)GamePhysics\;$(SolutionDir)Misc\;$(SolutionDir)WindowManager\;$(SolutionDir)OysterPhysics3D\;$(SolutionDir)Game\ServerDependencies;C:\Program Files %28x86%29\Visual Leak Detector\include;$(IncludePath)</IncludePath>
|
||||||
<LibraryPath>$(OutDir);$(SolutionDir)..\External\Lib\WindowManager\;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath)</LibraryPath>
|
<LibraryPath>$(OutDir);$(SolutionDir)..\External\Lib\WindowManager\;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(SolutionDir)..\External\Lib\ServerDependencies\;$(LibraryPath)</LibraryPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
<LinkIncremental>false</LinkIncremental>
|
<LinkIncremental>false</LinkIncremental>
|
||||||
<OutDir>$(SolutionDir)..\Bin\DLL\</OutDir>
|
<OutDir>$(SolutionDir)..\Bin\DLL\</OutDir>
|
||||||
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||||
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
|
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
|
||||||
<IncludePath>$(SolutionDir)..\External\Include\;$(SolutionDir)Game\GameProtocols\;$(SolutionDir)Game\GameLogic\;$(SolutionDir)Network\NetworkAPI\;$(SolutionDir)OysterMath\;$(SolutionDir)GamePhysics\;$(SolutionDir)Misc\;$(SolutionDir)WindowManager\;C:\Program Files %28x86%29\Visual Leak Detector\include;$(SolutionDir)OysterPhysics3D\;$(IncludePath)</IncludePath>
|
<IncludePath>$(SolutionDir)..\External\Include\;$(SolutionDir)Game\GameProtocols\;$(SolutionDir)Game\GameLogic\;$(SolutionDir)Network\NetworkAPI\;$(SolutionDir)OysterMath\;$(SolutionDir)GamePhysics\;$(SolutionDir)Misc\;$(SolutionDir)WindowManager\;$(SolutionDir)OysterPhysics3D\;$(SolutionDir)Game\ServerDependencies;C:\Program Files %28x86%29\Visual Leak Detector\include;$(IncludePath)</IncludePath>
|
||||||
<LibraryPath>$(OutDir);$(SolutionDir)..\External\Lib\WindowManager\;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath)</LibraryPath>
|
<LibraryPath>$(OutDir);$(SolutionDir)..\External\Lib\WindowManager\;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(SolutionDir)..\External\Lib\ServerDependencies\;$(LibraryPath)</LibraryPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
|
@ -173,39 +174,24 @@
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="AdminInterface\AdminInterface.cpp" />
|
<ClCompile Include="Implementation\DLLMain.cpp" />
|
||||||
<ClCompile Include="GameSession\GameSessionManager.cpp" />
|
<ClCompile Include="Implementation\GameClient.cpp" />
|
||||||
<ClCompile Include="DanBiasServerAPI.cpp" />
|
<ClCompile Include="Implementation\GameLobby.cpp" />
|
||||||
<ClCompile Include="DLLMain.cpp" />
|
<ClCompile Include="Implementation\GameServer.cpp" />
|
||||||
<ClCompile Include="GameServer.cpp" />
|
<ClCompile Include="Implementation\GameSession_General.cpp" />
|
||||||
<ClCompile Include="GameSession\GameClient.cpp" />
|
<ClCompile Include="Implementation\GameSession_Gameplay.cpp" />
|
||||||
<ClCompile Include="GameSession\GameSession_Events.cpp" />
|
<ClCompile Include="Implementation\GameLobby_ProtocolParser.cpp">
|
||||||
<ClCompile Include="GameSession\GameSession_General.cpp" />
|
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</ExcludedFromBuild>
|
||||||
<ClCompile Include="GameSession\GameSession_Network.cpp" />
|
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</ExcludedFromBuild>
|
||||||
<ClCompile Include="LobbySessions\INetworkSession.cpp" />
|
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild>
|
||||||
<ClCompile Include="LobbySessions\LobbyClient.cpp" />
|
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</ExcludedFromBuild>
|
||||||
<ClCompile Include="LobbySessions\GameLobby.cpp" />
|
</ClCompile>
|
||||||
<ClCompile Include="GameSession\GameSession_Logic.cpp" />
|
|
||||||
<ClCompile Include="LobbySessions\LobbyGeneralProtocolParser.cpp" />
|
|
||||||
<ClCompile Include="LobbySessions\LobbyProtocolParser.cpp" />
|
|
||||||
<ClCompile Include="LobbySessions\MainLobby.cpp" />
|
|
||||||
<ClCompile Include="LobbySessions\NetworkSession.cpp" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="AdminInterface\AdminInterface.h" />
|
<ClInclude Include="GameClient.h" />
|
||||||
<ClInclude Include="Event\EventManager.h" />
|
<ClInclude Include="GameLobby.h" />
|
||||||
<ClInclude Include="GameServer.h" />
|
<ClInclude Include="GameServerAPI.h" />
|
||||||
<ClInclude Include="GameSession\GameSessionManager.h" />
|
<ClInclude Include="GameSession.h" />
|
||||||
<ClInclude Include="DanBiasServerAPI.h" />
|
|
||||||
<ClInclude Include="Helpers\MapManager.h" />
|
|
||||||
<ClInclude Include="Helpers\ServerDataReader.h" />
|
|
||||||
<ClInclude Include="GameSession\GameClient.h" />
|
|
||||||
<ClInclude Include="GameSession\GameSession.h" />
|
|
||||||
<ClInclude Include="LobbySessions\INetworkSession.h" />
|
|
||||||
<ClInclude Include="LobbySessions\LobbyClient.h" />
|
|
||||||
<ClInclude Include="LobbySessions\GameLobby.h" />
|
|
||||||
<ClInclude Include="LobbySessions\MainLobby.h" />
|
|
||||||
<ClInclude Include="LobbySessions\NetworkSession.h" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\..\Misc\Misc.vcxproj">
|
<ProjectReference Include="..\..\Misc\Misc.vcxproj">
|
|
@ -20,16 +20,26 @@ namespace DanBias
|
||||||
{
|
{
|
||||||
DanBiasServerReturn_Error,
|
DanBiasServerReturn_Error,
|
||||||
DanBiasServerReturn_Sucess,
|
DanBiasServerReturn_Sucess,
|
||||||
|
DanBiasServerReturn_GameNotCreated,
|
||||||
};
|
};
|
||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
class DANBIAS_SERVER_DLL DanBiasServerAPI
|
class DANBIAS_SERVER_DLL GameServerAPI
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static DanBiasServerReturn Initiate();
|
struct GameInitDesc
|
||||||
static DanBiasServerReturn Run();
|
{
|
||||||
static DanBiasServerReturn Release();
|
int listenPort;
|
||||||
|
bool threaded;
|
||||||
|
};
|
||||||
|
|
||||||
|
public:
|
||||||
|
static DanBiasServerReturn Create(const GameInitDesc& desc);
|
||||||
|
static void Start();
|
||||||
|
static void Stop();
|
||||||
|
static void Terminate();
|
||||||
|
|
||||||
};//End class DanBiasServer
|
};//End class DanBiasServer
|
||||||
}//End Extern "C"
|
}//End Extern "C"
|
||||||
} //End namspace DanBias
|
} //End namspace DanBias
|
|
@ -0,0 +1,103 @@
|
||||||
|
/////////////////////////////////////////////////////////////////////
|
||||||
|
// Created by [Dennis Andersen] [2013]
|
||||||
|
/////////////////////////////////////////////////////////////////////
|
||||||
|
#ifndef DANBIASSERVER_GAME_SESSION_H
|
||||||
|
#define DANBIASSERVER_GAME_SESSION_H
|
||||||
|
|
||||||
|
//warning C4150: deletion of pointer to incomplete type, no destructor called, because of forward decleration and the use of smartpointer.
|
||||||
|
#pragma warning(disable: 4150)
|
||||||
|
|
||||||
|
|
||||||
|
#include "GameClient.h"
|
||||||
|
#include <WinTimer.h>
|
||||||
|
#include <PostBox\IPostBox.h>
|
||||||
|
#include <Thread\OysterThread.h>
|
||||||
|
#include <GameAPI.h>
|
||||||
|
#include <Queue.h>
|
||||||
|
#include <NetworkSession.h>
|
||||||
|
#include <DynamicArray.h>
|
||||||
|
#include <Protocols.h>
|
||||||
|
|
||||||
|
|
||||||
|
namespace DanBias
|
||||||
|
{
|
||||||
|
class GameSession : public Oyster::Network::NetworkSession
|
||||||
|
, public Oyster::Thread::IThreadObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A container to use when initiating a new session
|
||||||
|
*/
|
||||||
|
struct GameDescription
|
||||||
|
{
|
||||||
|
std::wstring mapName;
|
||||||
|
Oyster::Network::NetworkSession* owner;
|
||||||
|
Utility::DynamicMemory::DynamicArray<Oyster::Network::NetClient> clients;
|
||||||
|
};
|
||||||
|
|
||||||
|
public:
|
||||||
|
GameSession();
|
||||||
|
virtual~GameSession();
|
||||||
|
|
||||||
|
/** Initiates and creates a game session. */
|
||||||
|
bool Create(GameDescription& desc);
|
||||||
|
|
||||||
|
/** Runs the game session (ie starts the game loop). */
|
||||||
|
void Run();
|
||||||
|
|
||||||
|
/** Join an existing/running game session
|
||||||
|
* @param client The client to attach to the session
|
||||||
|
*/
|
||||||
|
bool Attach(Oyster::Network::NetClient client) override;
|
||||||
|
|
||||||
|
inline bool IsCreated() const { return this->isCreated; }
|
||||||
|
inline bool IsRunning() const { return this->isRunning; }
|
||||||
|
|
||||||
|
//Private member functions
|
||||||
|
private:
|
||||||
|
// TODO: find out what this method does..
|
||||||
|
void ClientEventCallback(Oyster::Network::NetEvent<Oyster::Network::NetworkClient*, Oyster::Network::NetworkClient::ClientEventArgs> e) override;
|
||||||
|
|
||||||
|
|
||||||
|
//Sends a client to the owner, if obj is NULL then all clients is sent
|
||||||
|
void SendToOwner(DanBias::GameClient* obj);
|
||||||
|
|
||||||
|
//Frame function, derived from IThreadObject
|
||||||
|
bool DoWork ( ) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void ParseProtocol (Oyster::Network::CustomNetProtocol& p, DanBias::GameClient* c);
|
||||||
|
|
||||||
|
void Gameplay_PlayerMovement ( GameLogic::Protocol_PlayerMovement& p, DanBias::GameClient* c );
|
||||||
|
void Gameplay_PlayerLookDir ( GameLogic::Protocol_PlayerLook& p, DanBias::GameClient* c );
|
||||||
|
void Gameplay_PlayerChangeWeapon ( GameLogic::Protocol_PlayerChangeWeapon& p, DanBias::GameClient* c );
|
||||||
|
void Gameplay_PlayerShot ( GameLogic::Protocol_PlayerShot& p, DanBias::GameClient* c );
|
||||||
|
void Gameplay_PlayerJump ( GameLogic::Protocol_PlayerJump& p, DanBias::GameClient* c );
|
||||||
|
void Gameplay_ObjectPickup ( GameLogic::Protocol_ObjectPickup& p, DanBias::GameClient* c );
|
||||||
|
void Gameplay_ObjectDamage ( GameLogic::Protocol_ObjectDamage& p, DanBias::GameClient* c );
|
||||||
|
void Gameplay_ObjectPosition ( GameLogic::Protocol_ObjectPosition& p, DanBias::GameClient* c );
|
||||||
|
void Gameplay_ObjectEnabled ( GameLogic::Protocol_ObjectEnable& p, DanBias::GameClient* c );
|
||||||
|
void Gameplay_ObjectDisabled ( GameLogic::Protocol_ObjectDisable& p, DanBias::GameClient* c );
|
||||||
|
void Gameplay_ObjectCreate ( GameLogic::Protocol_ObjectCreate& p, DanBias::GameClient* c );
|
||||||
|
void General_Status ( GameLogic::Protocol_General_Status& p, DanBias::GameClient* c );
|
||||||
|
void General_Text ( GameLogic::Protocol_General_Text& p, DanBias::GameClient* c );
|
||||||
|
|
||||||
|
//Private member variables
|
||||||
|
private:
|
||||||
|
Utility::DynamicMemory::DynamicArray<Utility::DynamicMemory::SmartPointer<GameClient>> clients;
|
||||||
|
Oyster::Thread::OysterThread worker;
|
||||||
|
GameLogic::GameAPI& gameInstance;
|
||||||
|
GameLogic::ILevelData *levelData;
|
||||||
|
NetworkSession* owner;
|
||||||
|
bool isCreated;
|
||||||
|
bool isRunning;
|
||||||
|
Utility::WinTimer timer;
|
||||||
|
|
||||||
|
//Callback method recieving from gamelogic
|
||||||
|
static void ObjectMove(GameLogic::IObjectData* movedObject);
|
||||||
|
|
||||||
|
|
||||||
|
};//End GameSession
|
||||||
|
}//End namespace DanBias
|
||||||
|
#endif // !DANBIASSERVER_GAME_SESSION_H
|
|
@ -0,0 +1,52 @@
|
||||||
|
/////////////////////////////////////////////////////////////////////
|
||||||
|
// Created by [Dennis Andersen] [2013]
|
||||||
|
/////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "..\GameClient.h"
|
||||||
|
#include <NetworkSession.h>
|
||||||
|
#include <Protocols.h>
|
||||||
|
|
||||||
|
using namespace Utility::DynamicMemory;
|
||||||
|
using namespace Oyster::Network;
|
||||||
|
using namespace DanBias;
|
||||||
|
using namespace GameLogic;
|
||||||
|
|
||||||
|
static int gameClientIDCount = 1;
|
||||||
|
|
||||||
|
GameClient::GameClient(SmartPointer<NetworkClient> client, GameLogic::IPlayerData* player)
|
||||||
|
{
|
||||||
|
this->client = client;
|
||||||
|
this->id = gameClientIDCount++;
|
||||||
|
this->player = player;
|
||||||
|
}
|
||||||
|
GameClient::~GameClient()
|
||||||
|
{
|
||||||
|
this->client->Disconnect();
|
||||||
|
this->player = 0;
|
||||||
|
this->id = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
GameLogic::IPlayerData* GameClient::GetPlayer()
|
||||||
|
{
|
||||||
|
return this->player;
|
||||||
|
}
|
||||||
|
GameLogic::IPlayerData* GameClient::ReleasePlayer()
|
||||||
|
{
|
||||||
|
GameLogic::IPlayerData *temp = this->player;
|
||||||
|
this->player = 0;
|
||||||
|
return temp;
|
||||||
|
}
|
||||||
|
SmartPointer<Oyster::Network::NetworkClient> GameClient::GetClient()
|
||||||
|
{
|
||||||
|
return this->client;
|
||||||
|
}
|
||||||
|
SmartPointer<Oyster::Network::NetworkClient> GameClient::ReleaseClient()
|
||||||
|
{
|
||||||
|
SmartPointer<Oyster::Network::NetworkClient> temp = this->client;
|
||||||
|
this->client = 0;
|
||||||
|
return temp;
|
||||||
|
}
|
||||||
|
int GameClient::GetID() const
|
||||||
|
{
|
||||||
|
return this->id;
|
||||||
|
}
|
|
@ -0,0 +1,62 @@
|
||||||
|
/////////////////////////////////////////////////////////////////////
|
||||||
|
// Created by [Dennis Andersen] [2013]
|
||||||
|
/////////////////////////////////////////////////////////////////////
|
||||||
|
#include "..\GameLobby.h"
|
||||||
|
#include <PlayerProtocols.h>
|
||||||
|
#include <PostBox\PostBox.h>
|
||||||
|
#include <Protocols.h>
|
||||||
|
|
||||||
|
using namespace Utility::DynamicMemory;
|
||||||
|
using namespace Oyster::Network;
|
||||||
|
using namespace Oyster;
|
||||||
|
|
||||||
|
namespace DanBias
|
||||||
|
{
|
||||||
|
GameLobby::GameLobby()
|
||||||
|
{ }
|
||||||
|
|
||||||
|
GameLobby::~GameLobby()
|
||||||
|
{ }
|
||||||
|
|
||||||
|
void GameLobby::Release()
|
||||||
|
{
|
||||||
|
NetworkSession::CloseSession(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameLobby::Update()
|
||||||
|
{
|
||||||
|
if(GetAsyncKeyState(VK_DOWN))
|
||||||
|
this->Send(*GameLogic::Protocol_General_Status().GetProtocol());
|
||||||
|
|
||||||
|
this->ProcessClients();
|
||||||
|
}
|
||||||
|
GameLobby::operator bool()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameLobby::ClientEventCallback(NetEvent<NetworkClient*, NetworkClient::ClientEventArgs> e)
|
||||||
|
{
|
||||||
|
switch (e.args.type)
|
||||||
|
{
|
||||||
|
case NetworkClient::ClientEventArgs::EventType_Disconnect:
|
||||||
|
break;
|
||||||
|
case NetworkClient::ClientEventArgs::EventType_ProtocolFailedToRecieve:
|
||||||
|
break;
|
||||||
|
case NetworkClient::ClientEventArgs::EventType_ProtocolFailedToSend:
|
||||||
|
printf("\t(%i : %s) - EventType_ProtocolFailedToSend\n", e.sender->GetID(), e.sender->GetIpAddress().c_str());
|
||||||
|
e.sender->Disconnect();
|
||||||
|
break;
|
||||||
|
case NetworkClient::ClientEventArgs::EventType_ProtocolRecieved:
|
||||||
|
printf("\t(%i : %s) - EventType_ProtocolRecieved\n", e.sender->GetID(), e.sender->GetIpAddress().c_str());
|
||||||
|
this->ParseProtocol(e.args.data.protocol, e.sender);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void GameLobby::ClientConnectedEvent(Utility::DynamicMemory::SmartPointer<Oyster::Network::NetworkClient> client)
|
||||||
|
{
|
||||||
|
printf("New client(%i) connected - %s \n", client->GetID(), client->GetIpAddress().c_str());
|
||||||
|
Attach(client);
|
||||||
|
}
|
||||||
|
|
||||||
|
}//End namespace DanBias
|
|
@ -0,0 +1,93 @@
|
||||||
|
#include "..\GameLobby.h"
|
||||||
|
|
||||||
|
using namespace DanBias;
|
||||||
|
using namespace GameLogic;
|
||||||
|
using namespace Oyster::Network;
|
||||||
|
|
||||||
|
|
||||||
|
void GameLobby::ParseProtocol(Oyster::Network::CustomNetProtocol& p, NetworkClient* c)
|
||||||
|
{
|
||||||
|
switch (p[0].value.netShort)
|
||||||
|
{
|
||||||
|
case protocol_General_Status: this->GeneralStatus (Protocol_General_Status (p), c);
|
||||||
|
break;
|
||||||
|
case protocol_General_Text: this->GeneralText (Protocol_General_Text (p), c);
|
||||||
|
break;
|
||||||
|
case protocol_Lobby_Create: this->LobbyCreateGame (Protocol_LobbyCreateGame (p), c);
|
||||||
|
break;
|
||||||
|
case protocol_Lobby_Start: this->LobbyStartGame (Protocol_LobbyStartGame (p), c);
|
||||||
|
break;
|
||||||
|
case protocol_Lobby_Join: this->LobbyJoin (Protocol_LobbyJoin (p), c);
|
||||||
|
break;
|
||||||
|
case protocol_Lobby_Login: this->LobbyLogin (Protocol_LobbyLogin (p), c);
|
||||||
|
break;
|
||||||
|
case protocol_Lobby_Refresh: this->LobbyRefresh (Protocol_LobbyRefresh (p), c);
|
||||||
|
break;
|
||||||
|
case protocol_Lobby_MainData: this->LobbyMainData (Protocol_LobbyMainData (p), c);
|
||||||
|
break;
|
||||||
|
case protocol_Lobby_GameData: this->LobbyGameData (Protocol_LobbyGameData (p), c);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GameLobby::GeneralStatus(GameLogic::Protocol_General_Status& p, Oyster::Network::NetworkClient* c)
|
||||||
|
{
|
||||||
|
switch (p.status)
|
||||||
|
{
|
||||||
|
case Protocol_General_Status::States_ready:
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
case Protocol_General_Status::States_idle:
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
case Protocol_General_Status::States_leave:
|
||||||
|
case Protocol_General_Status::States_disconected:
|
||||||
|
{
|
||||||
|
Detach(c)->Disconnect();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void GameLobby::GeneralText(GameLogic::Protocol_General_Text& p, Oyster::Network::NetworkClient* c)
|
||||||
|
{
|
||||||
|
printf(p.text.c_str());
|
||||||
|
}
|
||||||
|
void GameLobby::LobbyCreateGame(GameLogic::Protocol_LobbyCreateGame& p, Oyster::Network::NetworkClient* c)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
void GameLobby::LobbyStartGame(GameLogic::Protocol_LobbyStartGame& p, Oyster::Network::NetworkClient* c)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
void GameLobby::LobbyJoin(GameLogic::Protocol_LobbyJoin& p, Oyster::Network::NetworkClient* c)
|
||||||
|
{
|
||||||
|
//for (unsigned int i = 0; i < this->gameLobby.Size(); i++)
|
||||||
|
//{
|
||||||
|
// if (this->gameLobby[i]->GetID() == p.value)
|
||||||
|
// {
|
||||||
|
// this->gameLobby[i]->Attach(Detach(c));
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
void GameLobby::LobbyLogin(GameLogic::Protocol_LobbyLogin& p, Oyster::Network::NetworkClient* c)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
void GameLobby::LobbyRefresh(GameLogic::Protocol_LobbyRefresh& p, Oyster::Network::NetworkClient* c)
|
||||||
|
{
|
||||||
|
//Dont need to handle this on the server...
|
||||||
|
}
|
||||||
|
void GameLobby::LobbyMainData(GameLogic::Protocol_LobbyMainData& p, Oyster::Network::NetworkClient* c)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
void GameLobby::LobbyGameData(GameLogic::Protocol_LobbyGameData& p, Oyster::Network::NetworkClient* c)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,94 @@
|
||||||
|
/////////////////////////////////////////////////////////////////////
|
||||||
|
// Created by [Dennis Andersen] [2013]
|
||||||
|
/////////////////////////////////////////////////////////////////////
|
||||||
|
#define NOMINMAX
|
||||||
|
#include <Windows.h>
|
||||||
|
#include <iostream>
|
||||||
|
#include <vld.h>
|
||||||
|
|
||||||
|
#include "..\GameServerAPI.h"
|
||||||
|
#include "..\GameLobby.h"
|
||||||
|
#include "..\GameSession.h"
|
||||||
|
|
||||||
|
#include <NetworkServer.h>
|
||||||
|
#include <NetworkClient.h>
|
||||||
|
|
||||||
|
#include <WindowShell.h>
|
||||||
|
#include <Utilities.h>
|
||||||
|
#include <WinTimer.h>
|
||||||
|
#include <Thread\OysterThread.h>
|
||||||
|
|
||||||
|
using namespace DanBias;
|
||||||
|
using namespace Oyster::Network;
|
||||||
|
using namespace Oyster::Thread;
|
||||||
|
using namespace Utility;
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
GameLobby lobby;
|
||||||
|
NetworkServer server;
|
||||||
|
WinTimer timer;
|
||||||
|
GameServerAPI instance;
|
||||||
|
//typedef void(*WorkerThreadFnc)(GameServerAPI*);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
DanBiasServerReturn GameServerAPI::Create(const GameInitDesc& desc)
|
||||||
|
{
|
||||||
|
|
||||||
|
if(server.Init(desc.listenPort, &lobby) == NetworkServer::ServerReturnCode_Error)
|
||||||
|
{
|
||||||
|
return DanBiasServerReturn_Error;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::printf("Server created!\t-\t%s: [%i]\n\n", server.GetLanAddress().c_str(), desc.listenPort);
|
||||||
|
|
||||||
|
return DanBiasServerReturn_Sucess;
|
||||||
|
}
|
||||||
|
void GameServerAPI::Start()
|
||||||
|
{
|
||||||
|
server.Start();
|
||||||
|
|
||||||
|
timer.reset();
|
||||||
|
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
server.ProcessConnectedClients();
|
||||||
|
lobby.Update();
|
||||||
|
|
||||||
|
if(GetAsyncKeyState(0x51)) //Q for exit
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
double total = timer.getElapsedSeconds();
|
||||||
|
int time = (int)total;
|
||||||
|
int hour, min, sec;
|
||||||
|
|
||||||
|
hour=time / 3600;
|
||||||
|
time=time % 3600;
|
||||||
|
min=time / 60;
|
||||||
|
time=time % 60;
|
||||||
|
sec = time;
|
||||||
|
|
||||||
|
printf( "Server has been running for: %i:%i:%i - [hh:mm:ss] \n\n", hour, min, sec );
|
||||||
|
printf( "Terminating in : ");
|
||||||
|
for (int i = 0; i < 4; i++)
|
||||||
|
{
|
||||||
|
printf( "%i ", 3-i );
|
||||||
|
Sleep(1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
void GameServerAPI::Stop()
|
||||||
|
{
|
||||||
|
server.Stop();
|
||||||
|
lobby.ProcessClients();
|
||||||
|
}
|
||||||
|
void GameServerAPI::Terminate()
|
||||||
|
{
|
||||||
|
lobby.Release();
|
||||||
|
server.Shutdown();
|
||||||
|
|
||||||
|
printf( "Server terminated!" );
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,192 @@
|
||||||
|
/////////////////////////////////////////////////////////////////////
|
||||||
|
// Created by [Dennis Andersen] [2013]
|
||||||
|
/////////////////////////////////////////////////////////////////////
|
||||||
|
#include "..\GameSession.h"
|
||||||
|
#include "..\GameClient.h"
|
||||||
|
|
||||||
|
#include <Protocols.h>
|
||||||
|
#include <PostBox\PostBox.h>
|
||||||
|
#include <GameLogicStates.h>
|
||||||
|
#include <OysterMath.h>
|
||||||
|
#define NOMINMAX
|
||||||
|
#include <Windows.h>
|
||||||
|
|
||||||
|
#define DELTA_TIME_20 0.05f
|
||||||
|
#define DELTA_TIME_24 0.04166666666666666666666666666667f
|
||||||
|
#define DELTA_TIME_30 0.03333333333333333333333333333333f
|
||||||
|
#define DELTA_TIME_60 0.01666666666666666666666666666667f
|
||||||
|
#define DELTA_TIME_120 0.00833333333333333333333333333333f
|
||||||
|
|
||||||
|
using namespace Utility::DynamicMemory;
|
||||||
|
using namespace Oyster;
|
||||||
|
using namespace Oyster::Network;
|
||||||
|
using namespace Oyster::Thread;
|
||||||
|
using namespace GameLogic;
|
||||||
|
|
||||||
|
namespace DanBias
|
||||||
|
{
|
||||||
|
bool GameSession::DoWork( )
|
||||||
|
{
|
||||||
|
if(this->isRunning)
|
||||||
|
{
|
||||||
|
double dt = this->timer.getElapsedSeconds();
|
||||||
|
gameInstance.SetFrameTimeLength((float)dt);
|
||||||
|
|
||||||
|
if(dt >= DELTA_TIME_20)
|
||||||
|
{
|
||||||
|
this->ProcessClients();
|
||||||
|
|
||||||
|
this->gameInstance.NewFrame();
|
||||||
|
|
||||||
|
this->timer.reset();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return this->isRunning;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameSession::ClientEventCallback(NetEvent<NetworkClient*, NetworkClient::ClientEventArgs> e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameSession::ObjectMove(GameLogic::IObjectData* movedObject)
|
||||||
|
{
|
||||||
|
//GameLogic::IObjectData* obj = NULL;
|
||||||
|
//if(dynamic_cast<GameLogic::ILevelData*>(movedObject))
|
||||||
|
// obj =((GameLogic::ILevelData*)movedObject)->GetObjectAt(0);
|
||||||
|
//if(obj)
|
||||||
|
//{
|
||||||
|
// if(obj->GetType() == OBJECT_TYPE_BOX)
|
||||||
|
// {
|
||||||
|
// obj->GetID();
|
||||||
|
// Oyster::Math::Float4x4 world =obj->GetOrientation();
|
||||||
|
// Protocol_ObjectPosition p(world, 1);
|
||||||
|
// GameSession::gameSession->Send(p.GetProtocol());
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//*****************************************************//
|
||||||
|
//****************** Protocol methods *****************//
|
||||||
|
//******************************************************************************************************************//
|
||||||
|
|
||||||
|
void GameSession::ParseProtocol(Oyster::Network::CustomNetProtocol& p, DanBias::GameClient* c)
|
||||||
|
{
|
||||||
|
switch (p[protocol_INDEX_ID].value.netShort)
|
||||||
|
{
|
||||||
|
case protocol_Gameplay_PlayerMovement: this->Gameplay_PlayerMovement ( Protocol_PlayerMovement (p), c );
|
||||||
|
break;
|
||||||
|
case protocol_Gameplay_PlayerLookDir: this->Gameplay_PlayerLookDir ( Protocol_PlayerLook (p), c );
|
||||||
|
break;
|
||||||
|
case protocol_Gameplay_PlayerChangeWeapon: this->Gameplay_PlayerChangeWeapon ( Protocol_PlayerChangeWeapon (p), c );
|
||||||
|
break;
|
||||||
|
case protocol_Gameplay_PlayerShot: this->Gameplay_PlayerShot ( Protocol_PlayerShot (p), c );
|
||||||
|
break;
|
||||||
|
case protocol_Gameplay_PlayerJump: this->Gameplay_PlayerJump ( Protocol_PlayerJump (p), c );
|
||||||
|
break;
|
||||||
|
case protocol_Gameplay_ObjectPickup: this->Gameplay_ObjectPickup ( Protocol_ObjectPickup (p), c );
|
||||||
|
break;
|
||||||
|
case protocol_Gameplay_ObjectDamage: this->Gameplay_ObjectDamage ( Protocol_ObjectDamage (p), c );
|
||||||
|
break;
|
||||||
|
case protocol_Gameplay_ObjectPosition: this->Gameplay_ObjectPosition ( Protocol_ObjectPosition (p), c );
|
||||||
|
break;
|
||||||
|
case protocol_Gameplay_ObjectEnabled: this->Gameplay_ObjectEnabled ( Protocol_ObjectEnable (p), c );
|
||||||
|
break;
|
||||||
|
case protocol_Gameplay_ObjectDisabled: this->Gameplay_ObjectDisabled ( Protocol_ObjectDisable (p), c );
|
||||||
|
break;
|
||||||
|
case protocol_Gameplay_ObjectCreate: this->Gameplay_ObjectCreate ( Protocol_ObjectCreate (p), c );
|
||||||
|
break;
|
||||||
|
case protocol_General_Status: this->General_Status ( Protocol_General_Status (p), c );
|
||||||
|
break;
|
||||||
|
case protocol_General_Text: this->General_Text ( Protocol_General_Text (p), c );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameSession::Gameplay_PlayerMovement ( Protocol_PlayerMovement& p, DanBias::GameClient* c )
|
||||||
|
{
|
||||||
|
if(p.bForward) c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_FORWARD);
|
||||||
|
if(p.bBackward) c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_BACKWARD);
|
||||||
|
if(p.bLeft) c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_LEFT);
|
||||||
|
if(p.bRight) c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_RIGHT);
|
||||||
|
}
|
||||||
|
void GameSession::Gameplay_PlayerLookDir ( Protocol_PlayerLook& p, DanBias::GameClient* c )
|
||||||
|
{
|
||||||
|
Oyster::Math3D::Float3 lookDir;
|
||||||
|
lookDir.x = p.lookDirX;
|
||||||
|
lookDir.y = p.lookDirY;
|
||||||
|
lookDir.z = p.lookDirZ;
|
||||||
|
c->GetPlayer()->Rotate(lookDir);
|
||||||
|
}
|
||||||
|
void GameSession::Gameplay_PlayerChangeWeapon ( Protocol_PlayerChangeWeapon& p, DanBias::GameClient* c )
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
void GameSession::Gameplay_PlayerShot ( Protocol_PlayerShot& p, DanBias::GameClient* c )
|
||||||
|
{
|
||||||
|
c->GetPlayer()->UseWeapon(GameLogic::WEAPON_USE_PRIMARY_PRESS);
|
||||||
|
}
|
||||||
|
void GameSession::Gameplay_PlayerJump ( Protocol_PlayerJump& p, DanBias::GameClient* c )
|
||||||
|
{
|
||||||
|
if(p.hasJumped) c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_JUMP);
|
||||||
|
}
|
||||||
|
void GameSession::Gameplay_ObjectPickup ( Protocol_ObjectPickup& p, DanBias::GameClient* c )
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
void GameSession::Gameplay_ObjectDamage ( Protocol_ObjectDamage& p, DanBias::GameClient* c )
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
void GameSession::Gameplay_ObjectPosition ( Protocol_ObjectPosition& p, DanBias::GameClient* c )
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
void GameSession::Gameplay_ObjectEnabled ( Protocol_ObjectEnable& p, DanBias::GameClient* c )
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
void GameSession::Gameplay_ObjectDisabled ( Protocol_ObjectDisable& p, DanBias::GameClient* c )
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
void GameSession::Gameplay_ObjectCreate ( Protocol_ObjectCreate& p, DanBias::GameClient* c )
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
void GameSession::General_Status ( Protocol_General_Status& p, DanBias::GameClient* c )
|
||||||
|
{
|
||||||
|
switch (p.status)
|
||||||
|
{
|
||||||
|
case GameLogic::Protocol_General_Status::States_disconected:
|
||||||
|
printf("Client with ID [%i] dissconnected\n", c->GetClient()->GetID());
|
||||||
|
this->Detach(c->GetClient()->GetID());
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GameLogic::Protocol_General_Status::States_idle:
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GameLogic::Protocol_General_Status::States_ready:
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GameLogic::Protocol_General_Status::States_leave:
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void GameSession::General_Text ( Protocol_General_Text& p, DanBias::GameClient* c )
|
||||||
|
{
|
||||||
|
printf("Message recieved from (%i):\t %s\n", c->GetID(), p.text.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
}//End namespace DanBias
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
/////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////
|
||||||
// Created by [Dennis Andersen] [2013]
|
// Created by [Dennis Andersen] [2013]
|
||||||
/////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////
|
||||||
#include "GameSession.h"
|
#include "..\GameSession.h"
|
||||||
#include "GameClient.h"
|
#include "..\GameClient.h"
|
||||||
#include "..\GameServer.h"
|
|
||||||
#include <Protocols.h>
|
#include <Protocols.h>
|
||||||
#include <PostBox\PostBox.h>
|
#include <PostBox\PostBox.h>
|
||||||
#include <GameLogicStates.h>
|
#include <GameLogicStates.h>
|
||||||
|
|
||||||
|
#define NOMINMAX
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
|
|
||||||
|
|
||||||
|
@ -19,22 +19,22 @@ using namespace GameLogic;
|
||||||
|
|
||||||
namespace DanBias
|
namespace DanBias
|
||||||
{
|
{
|
||||||
GameSession* GameSession::gameSession = nullptr;
|
|
||||||
GameSession::GameSession()
|
GameSession::GameSession()
|
||||||
:gameInstance(GameAPI::Instance())
|
:gameInstance(GameAPI::Instance())
|
||||||
{
|
{
|
||||||
this->owner = 0;
|
this->owner = 0;
|
||||||
this->box = 0;
|
|
||||||
this->isCreated = false;
|
this->isCreated = false;
|
||||||
this->isRunning = false;
|
this->isRunning = false;
|
||||||
this->gameSession = this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GameSession::~GameSession()
|
GameSession::~GameSession()
|
||||||
{
|
{
|
||||||
delete this->box;
|
this->worker.Terminate();
|
||||||
this->box = 0;
|
this->clients.Clear();
|
||||||
|
this->gameInstance;
|
||||||
this->owner = 0;
|
this->owner = 0;
|
||||||
|
this->isCreated = false;
|
||||||
|
this->isRunning = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GameSession::Create(GameDescription& desc)
|
bool GameSession::Create(GameDescription& desc)
|
||||||
|
@ -47,7 +47,6 @@ namespace DanBias
|
||||||
|
|
||||||
/* standard initialization of some data */
|
/* standard initialization of some data */
|
||||||
this->clients.Resize(desc.clients.Size());
|
this->clients.Resize(desc.clients.Size());
|
||||||
this->box = new PostBox<NetworkSession::NetEvent>();
|
|
||||||
this->owner = desc.owner;
|
this->owner = desc.owner;
|
||||||
|
|
||||||
/* Initiate the game instance */
|
/* Initiate the game instance */
|
||||||
|
@ -63,18 +62,13 @@ namespace DanBias
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create a callback object */
|
|
||||||
Oyster::Callback::OysterCallback<void, NetworkSession::NetEvent> c;
|
|
||||||
c.value.callbackPostBox = this->box;
|
|
||||||
c.callbackType = Oyster::Callback::CallbackType_PostBox;
|
|
||||||
|
|
||||||
/* Create the players in the game instance */
|
/* Create the players in the game instance */
|
||||||
GameLogic::IPlayerData* p = 0;
|
GameLogic::IPlayerData* p = 0;
|
||||||
for (unsigned int i = 0; i < desc.clients.Size(); i++)
|
for (unsigned int i = 0; i < desc.clients.Size(); i++)
|
||||||
{
|
{
|
||||||
if( (p = this->gameInstance.CreatePlayer()) )
|
if( (p = this->gameInstance.CreatePlayer()) )
|
||||||
{
|
{
|
||||||
this->clients[i] = new GameClient(desc.clients[i], p, c);
|
this->clients[i] = new GameClient(desc.clients[i], p);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -83,7 +77,7 @@ namespace DanBias
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create the worker thread */
|
/* Create the worker thread */
|
||||||
if(this->worker.Create(this, true, true) != OYSTER_THREAD_ERROR_SUCCESS)
|
if(this->worker.Create(this, false) != OYSTER_THREAD_ERROR_SUCCESS)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
this->worker.SetPriority(Oyster::Thread::OYSTER_THREAD_PRIORITY_3);
|
this->worker.SetPriority(Oyster::Thread::OYSTER_THREAD_PRIORITY_3);
|
||||||
|
@ -97,106 +91,39 @@ namespace DanBias
|
||||||
|
|
||||||
void GameSession::Run()
|
void GameSession::Run()
|
||||||
{
|
{
|
||||||
|
|
||||||
if(this->isRunning) return;
|
if(this->isRunning) return;
|
||||||
|
|
||||||
if(this->clients.Size() > 0)
|
if(this->clients.Size() > 0)
|
||||||
{
|
{
|
||||||
|
this->worker.Start();
|
||||||
this->worker.SetPriority(OYSTER_THREAD_PRIORITY_1);
|
this->worker.SetPriority(OYSTER_THREAD_PRIORITY_1);
|
||||||
this->isRunning = true;
|
this->isRunning = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GameSession::Join(Utility::DynamicMemory::SmartPointer<LobbyClient> client)
|
|
||||||
|
|
||||||
|
bool GameSession::Attach(Utility::DynamicMemory::SmartPointer<NetworkClient> client)
|
||||||
{
|
{
|
||||||
if(!this->isCreated) return false;
|
if(!this->isCreated) return false;
|
||||||
|
|
||||||
Oyster::Callback::OysterCallback<void, DanBias::NetworkSession::NetEvent> c;
|
client->SetOwner(this);
|
||||||
c.value.callbackPostBox = this->box;
|
SmartPointer<GameClient> obj = new GameClient(client, this->gameInstance.CreatePlayer());
|
||||||
c.callbackType = Oyster::Callback::CallbackType_PostBox;
|
|
||||||
|
|
||||||
SmartPointer<GameClient> obj = new GameClient(client, this->gameInstance.CreatePlayer(), c);
|
|
||||||
InsertClient(obj);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GameSession::CloseSession(bool dissconnectClients)
|
|
||||||
{
|
|
||||||
if(dissconnectClients)
|
|
||||||
{
|
|
||||||
for (unsigned int i = 0; i < this->clients.Size(); i++)
|
|
||||||
{
|
|
||||||
this->clients[i]->GetClient()->Disconnect();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this->SendToOwner(0); //Send all clients to the current owner
|
|
||||||
}
|
|
||||||
this->Clean();
|
|
||||||
}
|
|
||||||
|
|
||||||
void GameSession::InsertClient(SmartPointer<GameClient> obj)
|
|
||||||
{
|
|
||||||
for (unsigned int i = 0; i < clients.Size(); i++)
|
for (unsigned int i = 0; i < clients.Size(); i++)
|
||||||
{
|
{
|
||||||
if(!clients[i])
|
if(!clients[i])
|
||||||
{
|
{
|
||||||
clients[i] = obj;
|
clients[i] = obj;
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
clients.Push(obj);
|
clients.Push(obj);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameSession::RemoveClient(DanBias::GameClient* obj)
|
|
||||||
{
|
|
||||||
for (unsigned int i = 0; i < clients.Size(); i++)
|
|
||||||
{
|
|
||||||
if(clients[i] && clients[i]->GetID() == obj->GetID())
|
|
||||||
{
|
|
||||||
clients[i] = 0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void GameSession::SendToOwner(DanBias::GameClient* obj)
|
|
||||||
{
|
|
||||||
DanBias::NetworkSession *s = GameServer::MainLobbyInstance();
|
|
||||||
|
|
||||||
if(this->owner) s = this->owner;
|
|
||||||
|
|
||||||
if(obj)
|
|
||||||
{
|
|
||||||
s->Attach(obj->ReleaseClient());
|
|
||||||
RemoveClient(obj);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (unsigned int i = 0; i < this->clients.Size(); i++)
|
|
||||||
{
|
|
||||||
if(this->clients[i])
|
|
||||||
{
|
|
||||||
s->Attach(this->clients[i]->ReleaseClient());
|
|
||||||
RemoveClient(this->clients[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void GameSession::Clean()
|
|
||||||
{
|
|
||||||
this->worker.Terminate();
|
|
||||||
this->clients.Clear();
|
|
||||||
delete this->box;
|
|
||||||
this->box = 0;
|
|
||||||
this->gameInstance;
|
|
||||||
this->owner = 0;
|
|
||||||
this->isCreated = false;
|
|
||||||
this->isRunning = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}//End namespace DanBias
|
}//End namespace DanBias
|
||||||
|
|
|
@ -4,18 +4,19 @@
|
||||||
#include <vld.h>
|
#include <vld.h>
|
||||||
|
|
||||||
#include "DanBiasGame.h"
|
#include "DanBiasGame.h"
|
||||||
#include <DanBiasServerAPI.h>
|
#include <GameServerAPI.h>
|
||||||
|
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
|
|
||||||
void ServerFnc()
|
void ServerFnc()
|
||||||
{
|
{
|
||||||
|
DanBias::GameServerAPI::GameInitDesc desc;
|
||||||
if( DanBias::DanBiasServerAPI::Initiate() == DanBias::DanBiasServerReturn_Sucess)
|
desc.listenPort = 15151;
|
||||||
|
if( DanBias::GameServerAPI::Create(desc) == DanBias::DanBiasServerReturn_Sucess)
|
||||||
{
|
{
|
||||||
DanBias::DanBiasServerAPI::Run();
|
DanBias::GameServerAPI::Start();
|
||||||
DanBias::DanBiasServerAPI::Release();
|
DanBias::GameServerAPI::Terminate();
|
||||||
}
|
}
|
||||||
Sleep(100);
|
Sleep(100);
|
||||||
}
|
}
|
||||||
|
@ -29,6 +30,7 @@ void ClientFnc()
|
||||||
//gameDesc.IP = "193.11.184.31";
|
//gameDesc.IP = "193.11.184.31";
|
||||||
//gameDesc.IP = "194.47.150.56";
|
//gameDesc.IP = "194.47.150.56";
|
||||||
gameDesc.IP = "127.0.0.1";
|
gameDesc.IP = "127.0.0.1";
|
||||||
|
//gameDesc.IP = "194.47.150.184";
|
||||||
|
|
||||||
if( DanBias::DanBiasGame::Initiate(gameDesc) == DanBias::DanBiasClientReturn_Sucess)
|
if( DanBias::DanBiasGame::Initiate(gameDesc) == DanBias::DanBiasClientReturn_Sucess)
|
||||||
{
|
{
|
||||||
|
|
|
@ -71,7 +71,7 @@
|
||||||
<OutDir>$(SolutionDir)..\Bin\Executable\</OutDir>
|
<OutDir>$(SolutionDir)..\Bin\Executable\</OutDir>
|
||||||
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||||
<TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName>
|
<TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName>
|
||||||
<IncludePath>$(SolutionDir)..\External\Include\;C:\Program Files %28x86%29\Visual Leak Detector\include;C:\Users\Dennis\Desktop\Skola\DV1477 - Stort spelutvecklingsprojekt\DanBias\Code\Game\DanBiasServer;$(IncludePath)</IncludePath>
|
<IncludePath>$(SolutionDir)..\External\Include\;C:\Program Files %28x86%29\Visual Leak Detector\include;$(SolutionDir)Game\GameServer;$(IncludePath)</IncludePath>
|
||||||
<LibraryPath>$(OutDir)..\DLL\;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath)</LibraryPath>
|
<LibraryPath>$(OutDir)..\DLL\;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath)</LibraryPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
@ -79,7 +79,7 @@
|
||||||
<OutDir>$(SolutionDir)..\Bin\Executable\</OutDir>
|
<OutDir>$(SolutionDir)..\Bin\Executable\</OutDir>
|
||||||
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||||
<TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName>
|
<TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName>
|
||||||
<IncludePath>$(SolutionDir)..\External\Include\;C:\Program Files %28x86%29\Visual Leak Detector\include;C:\Users\Dennis\Desktop\Skola\DV1477 - Stort spelutvecklingsprojekt\DanBias\Code\Game\DanBiasServer;$(IncludePath)</IncludePath>
|
<IncludePath>$(SolutionDir)..\External\Include\;C:\Program Files %28x86%29\Visual Leak Detector\include;$(SolutionDir)Game\GameServer;$(IncludePath)</IncludePath>
|
||||||
<LibraryPath>$(OutDir)..\DLL\;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath)</LibraryPath>
|
<LibraryPath>$(OutDir)..\DLL\;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath)</LibraryPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
@ -87,7 +87,7 @@
|
||||||
<OutDir>$(SolutionDir)..\Bin\Executable\</OutDir>
|
<OutDir>$(SolutionDir)..\Bin\Executable\</OutDir>
|
||||||
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||||
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
|
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
|
||||||
<IncludePath>$(SolutionDir)..\External\Include\;C:\Program Files %28x86%29\Visual Leak Detector\include;C:\Users\Dennis\Desktop\Skola\DV1477 - Stort spelutvecklingsprojekt\DanBias\Code\Game\DanBiasServer;$(IncludePath)</IncludePath>
|
<IncludePath>$(SolutionDir)..\External\Include\;C:\Program Files %28x86%29\Visual Leak Detector\include;$(SolutionDir)Game\GameServer;$(IncludePath)</IncludePath>
|
||||||
<LibraryPath>$(OutDir)..\DLL\;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath)</LibraryPath>
|
<LibraryPath>$(OutDir)..\DLL\;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath)</LibraryPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
@ -95,7 +95,7 @@
|
||||||
<OutDir>$(SolutionDir)..\Bin\Executable\</OutDir>
|
<OutDir>$(SolutionDir)..\Bin\Executable\</OutDir>
|
||||||
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||||
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
|
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
|
||||||
<IncludePath>$(SolutionDir)..\External\Include\;C:\Program Files %28x86%29\Visual Leak Detector\include;C:\Users\Dennis\Desktop\Skola\DV1477 - Stort spelutvecklingsprojekt\DanBias\Code\Game\DanBiasServer;$(IncludePath)</IncludePath>
|
<IncludePath>$(SolutionDir)..\External\Include\;C:\Program Files %28x86%29\Visual Leak Detector\include;$(SolutionDir)Game\GameServer;$(IncludePath)</IncludePath>
|
||||||
<LibraryPath>$(OutDir)..\DLL\;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath)</LibraryPath>
|
<LibraryPath>$(OutDir)..\DLL\;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath)</LibraryPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
@ -110,7 +110,7 @@
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<DelayLoadDLLs>DanBiasGame_$(PlatformShortName)D.dll;DanBiasServer_$(PlatformShortName)D.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
<DelayLoadDLLs>DanBiasGame_$(PlatformShortName)D.dll;GameServer_$(PlatformShortName)D.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
||||||
<AdditionalDependencies>DanBiasGame_$(PlatformShortName)D.lib;DanBiasServer_$(PlatformShortName)D.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>DanBiasGame_$(PlatformShortName)D.lib;DanBiasServer_$(PlatformShortName)D.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
|
@ -126,7 +126,7 @@
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<DelayLoadDLLs>DanBiasGame_$(PlatformShortName)D.dll;DanBiasServer_$(PlatformShortName)D.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
<DelayLoadDLLs>DanBiasGame_$(PlatformShortName)D.dll;GameServer_$(PlatformShortName)D.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
||||||
<AdditionalDependencies>DanBiasGame_$(PlatformShortName)D.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>DanBiasGame_$(PlatformShortName)D.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
|
@ -146,7 +146,7 @@
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
<DelayLoadDLLs>DanBiasGame_$(PlatformShortName).dll;DanBiasServer_$(PlatformShortName).dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
<DelayLoadDLLs>DanBiasGame_$(PlatformShortName).dll;GameServer_$(PlatformShortName).dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
||||||
<AdditionalDependencies>DanBiasGame_$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>DanBiasGame_$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
|
@ -166,7 +166,7 @@
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
<DelayLoadDLLs>DanBiasGame_$(PlatformShortName).dll;DanBiasServer_$(PlatformShortName).dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
<DelayLoadDLLs>DanBiasGame_$(PlatformShortName).dll;GameServer_$(PlatformShortName).dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
||||||
<AdditionalDependencies>DanBiasGame_$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>DanBiasGame_$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
|
@ -177,8 +177,8 @@
|
||||||
<ProjectReference Include="..\DanBiasGame\DanBiasGame.vcxproj">
|
<ProjectReference Include="..\DanBiasGame\DanBiasGame.vcxproj">
|
||||||
<Project>{2a1bc987-af42-4500-802d-89cd32fc1309}</Project>
|
<Project>{2a1bc987-af42-4500-802d-89cd32fc1309}</Project>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
<ProjectReference Include="..\DanBiasServer\DanBiasServer.vcxproj">
|
<ProjectReference Include="..\GameServer\GameServer.vcxproj">
|
||||||
<Project>{52380daa-0f4a-4d97-8e57-98df39319caf}</Project>
|
<Project>{143bd516-20a1-4890-a3e4-f8bfd02220e7}</Project>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
#ifndef MISC_DYNAMIC_ARRAY_H
|
#ifndef MISC_DYNAMIC_ARRAY_H
|
||||||
#define MISC_DYNAMIC_ARRAY_H
|
#define MISC_DYNAMIC_ARRAY_H
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
namespace Utility
|
namespace Utility
|
||||||
{
|
{
|
||||||
namespace DynamicMemory
|
namespace DynamicMemory
|
||||||
|
|
|
@ -72,8 +72,7 @@ namespace Oyster
|
||||||
//OYSTER_THREAD_ERROR Create(Oyster::Callback::CallbackFunction<bool, void>::FNC worker, bool start, bool detach = false);
|
//OYSTER_THREAD_ERROR Create(Oyster::Callback::CallbackFunction<bool, void>::FNC worker, bool start, bool detach = false);
|
||||||
OYSTER_THREAD_ERROR Start();
|
OYSTER_THREAD_ERROR Start();
|
||||||
OYSTER_THREAD_ERROR Stop();
|
OYSTER_THREAD_ERROR Stop();
|
||||||
OYSTER_THREAD_ERROR Pause();
|
OYSTER_THREAD_ERROR Stop(int msec);
|
||||||
OYSTER_THREAD_ERROR Pause(int mSec);
|
|
||||||
OYSTER_THREAD_ERROR Resume();
|
OYSTER_THREAD_ERROR Resume();
|
||||||
OYSTER_THREAD_ERROR SetWorker(IThreadObject* worker = 0);
|
OYSTER_THREAD_ERROR SetWorker(IThreadObject* worker = 0);
|
||||||
OYSTER_THREAD_ERROR SetWorker(ThreadFnc worker = 0);
|
OYSTER_THREAD_ERROR SetWorker(ThreadFnc worker = 0);
|
||||||
|
|
|
@ -118,15 +118,17 @@ using namespace Utility::DynamicMemory;
|
||||||
{
|
{
|
||||||
SmartPointer<RefData> data;
|
SmartPointer<RefData> data;
|
||||||
|
|
||||||
PrivateData(){}
|
PrivateData()
|
||||||
|
{
|
||||||
|
data = new RefData();
|
||||||
|
}
|
||||||
~PrivateData()
|
~PrivateData()
|
||||||
{
|
{
|
||||||
data.Release();
|
data = 0;
|
||||||
}
|
}
|
||||||
OYSTER_THREAD_ERROR Create(ThreadFunction fnc, OwnerContainer worker, bool start, bool detach)
|
OYSTER_THREAD_ERROR Create(ThreadFunction fnc, OwnerContainer worker, bool start, bool detach)
|
||||||
{
|
{
|
||||||
if(data) return OYSTER_THREAD_ERROR_ThreadAlreadyCreated;
|
if(!data) data = new RefData();
|
||||||
data = new RefData();
|
|
||||||
return data->Create(fnc, worker, start, detach);
|
return data->Create(fnc, worker, start, detach);
|
||||||
}
|
}
|
||||||
OYSTER_THREAD_ERROR Terminate()
|
OYSTER_THREAD_ERROR Terminate()
|
||||||
|
@ -205,9 +207,8 @@ using namespace Utility::DynamicMemory;
|
||||||
|
|
||||||
|
|
||||||
OysterThread::OysterThread()
|
OysterThread::OysterThread()
|
||||||
{
|
:privateData(0)
|
||||||
this->privateData = new PrivateData();
|
{ }
|
||||||
}
|
|
||||||
OysterThread::OysterThread(const OysterThread& original)
|
OysterThread::OysterThread(const OysterThread& original)
|
||||||
{
|
{
|
||||||
this->privateData = new PrivateData(*original.privateData);
|
this->privateData = new PrivateData(*original.privateData);
|
||||||
|
@ -257,15 +258,11 @@ OYSTER_THREAD_ERROR OysterThread::Start()
|
||||||
return OYSTER_THREAD_ERROR_SUCCESS;
|
return OYSTER_THREAD_ERROR_SUCCESS;
|
||||||
}
|
}
|
||||||
OYSTER_THREAD_ERROR OysterThread::Stop()
|
OYSTER_THREAD_ERROR OysterThread::Stop()
|
||||||
{
|
|
||||||
return this->Terminate();
|
|
||||||
}
|
|
||||||
OYSTER_THREAD_ERROR OysterThread::Pause()
|
|
||||||
{
|
{
|
||||||
this->privateData->data->threadData->state = OYSTER_THREAD_STATE_IDLE;
|
this->privateData->data->threadData->state = OYSTER_THREAD_STATE_IDLE;
|
||||||
return OYSTER_THREAD_ERROR_SUCCESS;
|
return OYSTER_THREAD_ERROR_SUCCESS;
|
||||||
}
|
}
|
||||||
OYSTER_THREAD_ERROR OysterThread::Pause(int msec)
|
OYSTER_THREAD_ERROR OysterThread::Stop(int msec)
|
||||||
{
|
{
|
||||||
this->privateData->data->threadData->msec = msec;
|
this->privateData->data->threadData->msec = msec;
|
||||||
return OYSTER_THREAD_ERROR_SUCCESS;
|
return OYSTER_THREAD_ERROR_SUCCESS;
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
/////////////////////////////////////////////
|
/////////////////////////////////////////////
|
||||||
|
|
||||||
#include "IQueue.h"
|
#include "IQueue.h"
|
||||||
|
#include <mutex>
|
||||||
|
|
||||||
namespace Utility
|
namespace Utility
|
||||||
{
|
{
|
||||||
|
@ -20,6 +21,7 @@ namespace Utility
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ThreadSafeQueue<Type>();
|
ThreadSafeQueue<Type>();
|
||||||
|
ThreadSafeQueue<Type>(const ThreadSafeQueue<Type>& obj);
|
||||||
virtual ~ThreadSafeQueue<Type>();
|
virtual ~ThreadSafeQueue<Type>();
|
||||||
|
|
||||||
virtual void Push( Type item );
|
virtual void Push( Type item );
|
||||||
|
@ -64,6 +66,12 @@ namespace Utility
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template < typename Type >
|
||||||
|
ThreadSafeQueue<Type>::ThreadSafeQueue(const ThreadSafeQueue<Type>& obj)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
template < typename Type >
|
template < typename Type >
|
||||||
ThreadSafeQueue<Type>::~ThreadSafeQueue()
|
ThreadSafeQueue<Type>::~ThreadSafeQueue()
|
||||||
{
|
{
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#ifndef WINTIMER_H
|
#ifndef WINTIMER_H
|
||||||
#define WINTIMER_H
|
#define WINTIMER_H
|
||||||
|
|
||||||
|
#define NOMINMAX
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
|
|
||||||
namespace Utility
|
namespace Utility
|
||||||
|
|
|
@ -4,36 +4,27 @@
|
||||||
#include "CustomNetProtocol.h"
|
#include "CustomNetProtocol.h"
|
||||||
#include <map>
|
#include <map>
|
||||||
#include "Translator.h"
|
#include "Translator.h"
|
||||||
|
#include "Utilities.h"
|
||||||
using namespace Oyster::Network;
|
using namespace Oyster::Network;
|
||||||
|
using namespace Utility::DynamicMemory;
|
||||||
|
|
||||||
|
|
||||||
struct CustomNetProtocol::PrivateData
|
struct CustomNetProtocol::PrivateData
|
||||||
{
|
{
|
||||||
std::map<int, NetAttributeContainer> attributes;
|
std::map<int, NetAttributeContainer> attributes; //...Im an idiot
|
||||||
|
Utility::DynamicMemory::ReferenceCount *c;
|
||||||
|
|
||||||
PrivateData()
|
PrivateData()
|
||||||
{ }
|
|
||||||
PrivateData( const CustomNetProtocol::PrivateData& o)
|
|
||||||
{
|
{
|
||||||
for (auto i = o.attributes.begin(); i != o.attributes.end(); i++)
|
//this->attributes = new std::map<int, NetAttributeContainer>();
|
||||||
{
|
this->c = new ReferenceCount();
|
||||||
if(i->second.type == NetAttributeType_CharArray)
|
c->Incref();
|
||||||
{
|
}
|
||||||
size_t size = strlen(i->second.value.netCharPtr);
|
|
||||||
if(size == 0) continue;
|
|
||||||
|
|
||||||
attributes[i->first].value.netCharPtr = new char[size + 1];
|
|
||||||
memcpy(&attributes[i->first].value.netCharPtr[0], &i->second.value.netCharPtr[0], size + 1);
|
|
||||||
attributes[i->first].type = NetAttributeType_CharArray;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
attributes[i->first] = i->second;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
~PrivateData()
|
~PrivateData()
|
||||||
{
|
{
|
||||||
|
delete c;
|
||||||
|
c = 0;
|
||||||
for (auto i = attributes.begin(); i != attributes.end(); i++)
|
for (auto i = attributes.begin(); i != attributes.end(); i++)
|
||||||
{
|
{
|
||||||
RemoveAttribute(i->first);
|
RemoveAttribute(i->first);
|
||||||
|
@ -49,7 +40,6 @@ struct CustomNetProtocol::PrivateData
|
||||||
{
|
{
|
||||||
case NetAttributeType_CharArray:
|
case NetAttributeType_CharArray:
|
||||||
delete [] i->second.value.netCharPtr;
|
delete [] i->second.value.netCharPtr;
|
||||||
//i->second.value.netCharPtr = 0;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -64,18 +54,41 @@ CustomNetProtocol::CustomNetProtocol()
|
||||||
}
|
}
|
||||||
CustomNetProtocol::CustomNetProtocol(const CustomNetProtocol& o)
|
CustomNetProtocol::CustomNetProtocol(const CustomNetProtocol& o)
|
||||||
{
|
{
|
||||||
this->privateData = new PrivateData(*o.privateData);
|
this->privateData = o.privateData;
|
||||||
|
if(this->privateData)
|
||||||
|
{
|
||||||
|
this->privateData->c = o.privateData->c;
|
||||||
|
this->privateData->c->Incref();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
const CustomNetProtocol& CustomNetProtocol::operator=(const CustomNetProtocol& o)
|
const CustomNetProtocol& CustomNetProtocol::operator=(const CustomNetProtocol& o)
|
||||||
|
{
|
||||||
|
if(this->privateData && this->privateData->c)
|
||||||
|
{
|
||||||
|
if(this->privateData->c->Decref() == 0)
|
||||||
{
|
{
|
||||||
delete this->privateData;
|
delete this->privateData;
|
||||||
this->privateData = new PrivateData(*o.privateData);
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this->privateData = o.privateData;
|
||||||
|
if(this->privateData)
|
||||||
|
{
|
||||||
|
this->privateData->c = o.privateData->c;
|
||||||
|
this->privateData->c->Incref();
|
||||||
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
CustomNetProtocol::~CustomNetProtocol()
|
CustomNetProtocol::~CustomNetProtocol()
|
||||||
|
{
|
||||||
|
if(this->privateData && this->privateData->c)
|
||||||
|
{
|
||||||
|
if(this->privateData->c->Decref() == 0)
|
||||||
{
|
{
|
||||||
delete this->privateData;
|
delete this->privateData;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
NetAttributeContainer& CustomNetProtocol::operator[](int ID)
|
NetAttributeContainer& CustomNetProtocol::operator[](int ID)
|
||||||
{
|
{
|
||||||
if(this->privateData->attributes.find(ID) == this->privateData->attributes.end())
|
if(this->privateData->attributes.find(ID) == this->privateData->attributes.end())
|
||||||
|
|
|
@ -6,12 +6,7 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
//#include <vld.h>
|
//#include <vld.h>
|
||||||
|
#include "NetworkAPI_Preprocessor.h"
|
||||||
#ifdef CUSTOM_NET_PROTOCOL_EXPORT
|
|
||||||
#define NET_PROTOCOL_EXPORT __declspec(dllexport)
|
|
||||||
#else
|
|
||||||
#define NET_PROTOCOL_EXPORT __declspec(dllimport)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace Oyster
|
namespace Oyster
|
||||||
{
|
{
|
||||||
|
@ -78,7 +73,7 @@ namespace Oyster
|
||||||
virtual CustomNetProtocol* GetProtocol() = 0;
|
virtual CustomNetProtocol* GetProtocol() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class NET_PROTOCOL_EXPORT CustomNetProtocol
|
class NET_API_EXPORT CustomNetProtocol
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CustomNetProtocol();
|
CustomNetProtocol();
|
||||||
|
|
|
@ -88,16 +88,16 @@
|
||||||
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||||
<OutDir>$(SolutionDir)..\Bin\DLL\</OutDir>
|
<OutDir>$(SolutionDir)..\Bin\DLL\</OutDir>
|
||||||
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
|
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
|
||||||
<IncludePath>C:\Program Files %28x86%29\Visual Leak Detector\include;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSDK_IncludePath);</IncludePath>
|
<IncludePath>C:\Program Files %28x86%29\Visual Leak Detector\include;$(IncludePath)</IncludePath>
|
||||||
<LibraryPath>C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(VCInstallDir)lib;$(VCInstallDir)atlmfc\lib;$(WindowsSDK_LibraryPath_x86);</LibraryPath>
|
<LibraryPath>C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath)</LibraryPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
<LinkIncremental>false</LinkIncremental>
|
<LinkIncremental>false</LinkIncremental>
|
||||||
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||||
<OutDir>$(SolutionDir)..\Bin\DLL\</OutDir>
|
<OutDir>$(SolutionDir)..\Bin\DLL\</OutDir>
|
||||||
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
|
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
|
||||||
<LibraryPath>C:\Program Files %28x86%29\Visual Leak Detector\lib\Win64;$(VCInstallDir)lib\amd64;$(VCInstallDir)atlmfc\lib\amd64;$(WindowsSDK_LibraryPath_x64);</LibraryPath>
|
<LibraryPath>C:\Program Files %28x86%29\Visual Leak Detector\lib\Win64;$(LibraryPath)</LibraryPath>
|
||||||
<IncludePath>C:\Program Files %28x86%29\Visual Leak Detector\include;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSDK_IncludePath);</IncludePath>
|
<IncludePath>C:\Program Files %28x86%29\Visual Leak Detector\include;$(IncludePath)</IncludePath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
|
@ -105,8 +105,9 @@
|
||||||
</PrecompiledHeader>
|
</PrecompiledHeader>
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<PreprocessorDefinitions>CUSTOM_NET_PROTOCOL_EXPORT;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>NETWORKAPI_EXPORT;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<AdditionalIncludeDirectories>$(SolutionDir)Misc\</AdditionalIncludeDirectories>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
|
@ -119,8 +120,9 @@
|
||||||
</PrecompiledHeader>
|
</PrecompiledHeader>
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<PreprocessorDefinitions>CUSTOM_NET_PROTOCOL_EXPORT;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>NETWORKAPI_EXPORT;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<AdditionalIncludeDirectories>$(SolutionDir)Misc\</AdditionalIncludeDirectories>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
|
@ -135,8 +137,9 @@
|
||||||
<Optimization>MaxSpeed</Optimization>
|
<Optimization>MaxSpeed</Optimization>
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<PreprocessorDefinitions>CUSTOM_NET_PROTOCOL_EXPORT;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>NETWORKAPI_EXPORT;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<AdditionalIncludeDirectories>$(SolutionDir)Misc\</AdditionalIncludeDirectories>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
|
@ -153,8 +156,9 @@
|
||||||
<Optimization>MaxSpeed</Optimization>
|
<Optimization>MaxSpeed</Optimization>
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<PreprocessorDefinitions>CUSTOM_NET_PROTOCOL_EXPORT;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>NETWORKAPI_EXPORT;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<AdditionalIncludeDirectories>$(SolutionDir)Misc\</AdditionalIncludeDirectories>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
|
@ -167,13 +171,16 @@
|
||||||
<ClCompile Include="CustomNetProtocol.cpp" />
|
<ClCompile Include="CustomNetProtocol.cpp" />
|
||||||
<ClCompile Include="NetworkServer.cpp" />
|
<ClCompile Include="NetworkServer.cpp" />
|
||||||
<ClCompile Include="NetworkClient.cpp" />
|
<ClCompile Include="NetworkClient.cpp" />
|
||||||
|
<ClCompile Include="NetworkSession.cpp" />
|
||||||
<ClCompile Include="Translator.cpp" />
|
<ClCompile Include="Translator.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="CustomNetProtocol.h" />
|
<ClInclude Include="CustomNetProtocol.h" />
|
||||||
<ClInclude Include="NetworkCallbackHelper.h" />
|
<ClInclude Include="NetworkAPI_Preprocessor.h" />
|
||||||
<ClInclude Include="NetworkServer.h" />
|
<ClInclude Include="NetworkServer.h" />
|
||||||
<ClInclude Include="NetworkClient.h" />
|
<ClInclude Include="NetworkClient.h" />
|
||||||
|
<ClInclude Include="NetworkServerEventStruct.h" />
|
||||||
|
<ClInclude Include="NetworkSession.h" />
|
||||||
<ClInclude Include="Translator.h" />
|
<ClInclude Include="Translator.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
#ifndef NETWORK_API_NETWORK_API_PREPROCESSOR_H
|
||||||
|
#define NETWORK_API_NETWORK_API_PREPROCESSOR_H
|
||||||
|
|
||||||
|
#ifdef NETWORKAPI_EXPORT
|
||||||
|
#define NET_API_EXPORT __declspec(dllexport)
|
||||||
|
#else
|
||||||
|
#define NET_API_EXPORT __declspec(dllimport)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // !NETWORK_API_NETWORK_API_PREPROCESSOR_H
|
|
@ -1,80 +0,0 @@
|
||||||
#ifndef NETWORK_API_NETWORK_CALLBACK_HELPER_H
|
|
||||||
#define NETWORK_API_NETWORK_CALLBACK_HELPER_H
|
|
||||||
|
|
||||||
/////////////////////////////////////
|
|
||||||
// Created by Dennis Andersen 2013 //
|
|
||||||
/////////////////////////////////////
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
|
|
||||||
namespace Oyster
|
|
||||||
{
|
|
||||||
namespace Network
|
|
||||||
{
|
|
||||||
enum NetworkProtocolCallbackType
|
|
||||||
{
|
|
||||||
NetworkProtocolCallbackType_Function,
|
|
||||||
NetworkProtocolCallbackType_Object,
|
|
||||||
NetworkProtocolCallbackType_Unknown = -1,
|
|
||||||
};
|
|
||||||
enum NetworkClientCallbackType
|
|
||||||
{
|
|
||||||
NetworkClientCallbackType_Function,
|
|
||||||
NetworkClientCallbackType_Object,
|
|
||||||
NetworkClientCallbackType_Unknown = -1,
|
|
||||||
};
|
|
||||||
|
|
||||||
class NetworkClient;
|
|
||||||
class CustomNetProtocol;
|
|
||||||
|
|
||||||
|
|
||||||
template<typename Param>
|
|
||||||
struct NetRecieverObject
|
|
||||||
{
|
|
||||||
virtual void NetworkCallback(Param) = 0;
|
|
||||||
};
|
|
||||||
struct NetClientEvent :public NetRecieverObject<CustomNetProtocol&>
|
|
||||||
{
|
|
||||||
virtual void NetworkCallback(CustomNetProtocol& protocol) = 0;
|
|
||||||
virtual void Disconnected() { };
|
|
||||||
};
|
|
||||||
typedef NetRecieverObject<NetworkClient*> ClientConnectedObject ;
|
|
||||||
typedef NetClientEvent ProtocolRecieverObject;
|
|
||||||
|
|
||||||
|
|
||||||
template <typename Param>
|
|
||||||
struct NetCallbackFunction
|
|
||||||
{
|
|
||||||
typedef void (*FNC)(Param);
|
|
||||||
};
|
|
||||||
typedef NetCallbackFunction<NetworkClient*>::FNC ClientConnectCallbackMethod;
|
|
||||||
typedef NetCallbackFunction<CustomNetProtocol&>::FNC ProtocolRecFunction;
|
|
||||||
struct NetClientMethods
|
|
||||||
{
|
|
||||||
typedef void(*Dissconnected)(void);
|
|
||||||
ProtocolRecFunction recieved;
|
|
||||||
Dissconnected dissconnected;
|
|
||||||
void operator()(CustomNetProtocol& obj) { if(recieved) recieved(obj); }
|
|
||||||
void operator()() { if(dissconnected) dissconnected(); }
|
|
||||||
};
|
|
||||||
typedef NetClientMethods ProtocolRecieverFunction;
|
|
||||||
|
|
||||||
union RecieverObject
|
|
||||||
{
|
|
||||||
ClientConnectCallbackMethod clientConnectFnc; // !< A function pointer for sending or recieving NetworkClient
|
|
||||||
ProtocolRecieverFunction protocolRecieverFnc; // !< A function pointer for sending or recieving CustomNetProtocol
|
|
||||||
|
|
||||||
ClientConnectedObject *clientConnectObject; // !< An object for sending or recieving NetworkClient
|
|
||||||
ProtocolRecieverObject *protocolRecievedObject; // !< An object with collected client events methods.
|
|
||||||
|
|
||||||
RecieverObject() { memset(this, 0, sizeof(RecieverObject)); }
|
|
||||||
RecieverObject(ClientConnectCallbackMethod o) { clientConnectFnc = o; }
|
|
||||||
RecieverObject(ProtocolRecieverFunction o) { protocolRecieverFnc = o; }
|
|
||||||
RecieverObject(ClientConnectedObject* o) { clientConnectObject = o; }
|
|
||||||
RecieverObject(ProtocolRecieverObject* o) { protocolRecievedObject = o; }
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
#include "Translator.h"
|
#include "Translator.h"
|
||||||
#include "CustomNetProtocol.h"
|
#include "CustomNetProtocol.h"
|
||||||
|
#include "NetworkSession.h"
|
||||||
|
|
||||||
#include "../NetworkDependencies/Connection.h"
|
#include "../NetworkDependencies/Connection.h"
|
||||||
#include "../NetworkDependencies/PostBox.h"
|
#include "../NetworkDependencies/PostBox.h"
|
||||||
|
@ -19,274 +20,237 @@
|
||||||
using namespace Oyster::Network;
|
using namespace Oyster::Network;
|
||||||
using namespace Oyster::Thread;
|
using namespace Oyster::Thread;
|
||||||
using namespace Utility::DynamicMemory;
|
using namespace Utility::DynamicMemory;
|
||||||
|
using namespace Utility::Container;
|
||||||
|
|
||||||
/*************************************
|
/*************************************
|
||||||
PrivateData
|
PrivateData
|
||||||
*************************************/
|
*************************************/
|
||||||
struct ClientDataContainer
|
typedef NetworkClient::ClientEventArgs CEA;
|
||||||
|
|
||||||
|
struct NetworkClient::PrivateData : public IThreadObject
|
||||||
{
|
{
|
||||||
|
NetworkSession *owner;
|
||||||
|
NetworkClient *parent;
|
||||||
Connection connection;
|
Connection connection;
|
||||||
|
|
||||||
SmartPointer<IPostBox<CustomNetProtocol>> sendPostBox;
|
|
||||||
|
|
||||||
RecieverObject recvObj;
|
|
||||||
NetworkProtocolCallbackType callbackType;
|
|
||||||
|
|
||||||
Oyster::Thread::OysterThread thread;
|
|
||||||
std::mutex recvObjMutex;
|
|
||||||
std::mutex postBoxMutex;
|
|
||||||
|
|
||||||
Translator translator;
|
Translator translator;
|
||||||
|
OysterThread thread;
|
||||||
|
|
||||||
|
|
||||||
|
//Message queue for sending and recieving
|
||||||
|
ThreadSafeQueue<CustomNetProtocol> sendQueue;
|
||||||
|
ThreadSafeQueue<NetEvent<NetworkClient*, NetworkClient::ClientEventArgs>> recieveQueue;
|
||||||
|
|
||||||
//ID
|
//ID
|
||||||
static unsigned int currID;
|
static unsigned int currID;
|
||||||
const unsigned int ID;
|
const unsigned int ID;
|
||||||
|
|
||||||
ClientDataContainer(IThreadObject* o)
|
PrivateData()
|
||||||
: ID(currID++)
|
: ID(currID++)
|
||||||
|
, parent(0)
|
||||||
|
, owner(0)
|
||||||
{
|
{
|
||||||
InitWinSock();
|
|
||||||
callbackType = NetworkProtocolCallbackType_Unknown;
|
|
||||||
sendPostBox = new PostBox<CustomNetProtocol>();
|
|
||||||
connection.InitiateClient();
|
|
||||||
connection.SetBlockingMode(false);
|
|
||||||
|
|
||||||
}
|
|
||||||
ClientDataContainer(IThreadObject* o, unsigned int socket )
|
|
||||||
:connection(socket), ID(currID++)
|
|
||||||
{
|
|
||||||
InitWinSock();
|
InitWinSock();
|
||||||
callbackType = NetworkProtocolCallbackType_Unknown;
|
this->thread.Create(this, false);
|
||||||
sendPostBox = new PostBox<CustomNetProtocol>();
|
this->thread.SetPriority(Oyster::Thread::OYSTER_THREAD_PRIORITY_1);
|
||||||
connection.InitiateClient();
|
|
||||||
connection.SetBlockingMode(false);
|
|
||||||
}
|
}
|
||||||
~ClientDataContainer()
|
~PrivateData()
|
||||||
{
|
{
|
||||||
connection.Disconnect();
|
|
||||||
thread.Stop();
|
|
||||||
callbackType = NetworkProtocolCallbackType_Unknown;
|
|
||||||
|
|
||||||
ShutdownWinSock();
|
ShutdownWinSock();
|
||||||
|
this->connection.Disconnect();
|
||||||
|
this->thread.Terminate();
|
||||||
|
this->owner = 0;
|
||||||
|
this->parent = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
bool DoWork() override
|
||||||
unsigned int ClientDataContainer::currID = 0;
|
|
||||||
|
|
||||||
|
|
||||||
struct NetworkClient::PrivateData : public IThreadObject
|
|
||||||
{
|
{
|
||||||
Utility::DynamicMemory::SmartPointer<ClientDataContainer> data;
|
if(!this->connection.IsConnected()) return false;
|
||||||
|
|
||||||
PrivateData() { this->data = new ClientDataContainer(this); }
|
|
||||||
PrivateData(unsigned int socket) { this->data = new ClientDataContainer(this, socket); }
|
|
||||||
~PrivateData() { }
|
|
||||||
|
|
||||||
bool DoWork()
|
|
||||||
{
|
|
||||||
if(!this->data) return false;
|
|
||||||
if(!this->data->connection.IsConnected()) return false;
|
|
||||||
|
|
||||||
Send();
|
Send();
|
||||||
Recv();
|
Recv();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Send(CustomNetProtocol* protocol)
|
|
||||||
{
|
|
||||||
if(!data) return;
|
|
||||||
|
|
||||||
this->data->postBoxMutex.lock();
|
|
||||||
this->data->sendPostBox->PostMessage(*protocol);
|
|
||||||
this->data->postBoxMutex.unlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
int Send()
|
int Send()
|
||||||
{
|
{
|
||||||
int errorCode = 0;
|
int errorCode = 0;
|
||||||
if(!data) return -1;
|
|
||||||
|
|
||||||
this->data->postBoxMutex.lock();
|
if(!this->sendQueue.IsEmpty())
|
||||||
if(this->data->sendPostBox->IsFull())
|
|
||||||
{
|
{
|
||||||
SmartPointer<OysterByte> temp = new OysterByte();
|
SmartPointer<OysterByte> temp = new OysterByte();
|
||||||
this->data->translator.Pack(temp, this->data->sendPostBox->FetchMessage());
|
CustomNetProtocol p = this->sendQueue.Pop();
|
||||||
errorCode = this->data->connection.Send(temp);
|
this->translator.Pack(temp, p);
|
||||||
|
errorCode = this->connection.Send(temp);
|
||||||
if(errorCode != 0)
|
if(errorCode != 0)
|
||||||
{
|
{
|
||||||
//Failed
|
CEA parg;
|
||||||
this->data->connection.Disconnect();
|
parg.type = CEA::EventType_ProtocolFailedToSend;
|
||||||
|
parg.data.protocol = p;
|
||||||
this->data->recvObjMutex.lock();
|
NetEvent<NetworkClient*, CEA> e = { this->parent, parg };
|
||||||
if(this->data->callbackType == NetworkProtocolCallbackType_Function)
|
this->recieveQueue.Push(e);
|
||||||
{
|
|
||||||
this->data->recvObj.protocolRecieverFnc();
|
|
||||||
}
|
|
||||||
else if(this->data->callbackType == NetworkProtocolCallbackType_Object)
|
|
||||||
{
|
|
||||||
this->data->recvObj.protocolRecievedObject->Disconnected();
|
|
||||||
}
|
|
||||||
this->data->recvObjMutex.unlock();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this->data->postBoxMutex.unlock();
|
|
||||||
|
|
||||||
return errorCode;
|
return errorCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Recv()
|
int Recv()
|
||||||
{
|
{
|
||||||
int errorCode = -1;
|
int errorCode = -1;
|
||||||
|
|
||||||
OysterByte temp = OysterByte();
|
OysterByte temp = OysterByte();
|
||||||
errorCode = this->data->connection.Recieve(temp);
|
errorCode = this->connection.Recieve(temp);
|
||||||
|
|
||||||
if(errorCode == 0 && temp.GetSize())
|
if(errorCode == 0 && temp.GetSize())
|
||||||
{
|
{
|
||||||
CustomNetProtocol protocol;
|
CustomNetProtocol protocol;
|
||||||
bool ok = this->data->translator.Unpack(protocol, temp);
|
bool ok = this->translator.Unpack(protocol, temp);
|
||||||
|
|
||||||
//Check if the protocol was unpacked correctly
|
//Check if the protocol was unpacked correctly
|
||||||
if(ok)
|
if(ok)
|
||||||
{
|
{
|
||||||
this->data->recvObjMutex.lock();
|
CEA parg;
|
||||||
if(this->data->callbackType == NetworkProtocolCallbackType_Function)
|
parg.type = CEA::EventType_ProtocolRecieved;
|
||||||
{
|
parg.data.protocol = protocol;
|
||||||
this->data->recvObj.protocolRecieverFnc(protocol);
|
NetEvent<NetworkClient*, NetworkClient::ClientEventArgs> e = { this->parent, parg };
|
||||||
}
|
this->recieveQueue.Push(e);
|
||||||
else if(this->data->callbackType == NetworkProtocolCallbackType_Object)
|
|
||||||
{
|
|
||||||
this->data->recvObj.protocolRecievedObject->NetworkCallback(protocol);
|
|
||||||
}
|
|
||||||
this->data->recvObjMutex.unlock();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//else
|
||||||
|
//{
|
||||||
|
// CEA parg;
|
||||||
|
// parg.type = CEA::EventType_ProtocolFailedToRecieve;
|
||||||
|
// parg.data.nothing = 0;
|
||||||
|
// NetEvent<NetworkClient*, NetworkClient::ClientEventArgs> e = { this->parent, parg };
|
||||||
|
// this->recieveQueue.Push(e);
|
||||||
|
//}
|
||||||
|
|
||||||
return errorCode;
|
return errorCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
unsigned int NetworkClient::PrivateData::currID = 0;
|
||||||
|
|
||||||
/*************************************
|
/*************************************
|
||||||
NetworkClient
|
NetworkClient
|
||||||
*************************************/
|
*************************************/
|
||||||
|
|
||||||
NetworkClient::NetworkClient()
|
NetworkClient::NetworkClient()
|
||||||
{
|
: privateData(0)
|
||||||
privateData = new PrivateData();
|
{ }
|
||||||
this->privateData->data->thread.SetPriority(Oyster::Thread::OYSTER_THREAD_PRIORITY_1);
|
|
||||||
}
|
|
||||||
|
|
||||||
NetworkClient::NetworkClient(unsigned int socket)
|
|
||||||
{
|
|
||||||
privateData = new PrivateData(socket);
|
|
||||||
this->privateData->data->thread.Create(this->privateData, true);
|
|
||||||
this->privateData->data->thread.SetPriority(Oyster::Thread::OYSTER_THREAD_PRIORITY_1);
|
|
||||||
}
|
|
||||||
|
|
||||||
NetworkClient::NetworkClient(RecieverObject recvObj, NetworkProtocolCallbackType type)
|
|
||||||
{
|
|
||||||
privateData = new PrivateData();
|
|
||||||
this->privateData->data->callbackType = type;
|
|
||||||
this->privateData->data->recvObj = recvObj;
|
|
||||||
}
|
|
||||||
|
|
||||||
NetworkClient::NetworkClient(RecieverObject recvObj, NetworkProtocolCallbackType type, unsigned int socket)
|
|
||||||
{
|
|
||||||
privateData = new PrivateData(socket);
|
|
||||||
this->privateData->data->callbackType = type;
|
|
||||||
this->privateData->data->recvObj = recvObj;
|
|
||||||
this->privateData->data->thread.Create(this->privateData, true);
|
|
||||||
this->privateData->data->thread.SetPriority(Oyster::Thread::OYSTER_THREAD_PRIORITY_1);
|
|
||||||
}
|
|
||||||
|
|
||||||
NetworkClient::NetworkClient(const NetworkClient& obj)
|
|
||||||
{
|
|
||||||
this->privateData = new PrivateData(*obj.privateData);
|
|
||||||
}
|
|
||||||
|
|
||||||
NetworkClient& NetworkClient::operator =(const NetworkClient& obj)
|
|
||||||
{
|
|
||||||
delete privateData;
|
|
||||||
this->privateData = new PrivateData(*obj.privateData);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
NetworkClient::~NetworkClient()
|
NetworkClient::~NetworkClient()
|
||||||
{
|
{
|
||||||
if(privateData)
|
if(this->privateData)
|
||||||
{
|
{
|
||||||
delete privateData;
|
delete this->privateData;
|
||||||
privateData = NULL;
|
this->privateData = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NetworkClient::Connect(unsigned short port, const char serverIP[])
|
|
||||||
{
|
|
||||||
privateData->data->connection.SetBlockingMode(true);
|
|
||||||
int result = this->privateData->data->connection.Connect(port, serverIP);
|
|
||||||
|
|
||||||
//Connect has succeeded
|
|
||||||
if(result == 0)
|
|
||||||
{
|
|
||||||
if(this->privateData->data->thread.IsCreated()) return false;
|
|
||||||
|
|
||||||
this->privateData->data->thread.Create(this->privateData, true);
|
|
||||||
privateData->data->connection.SetBlockingMode(false);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Connect has failed
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void NetworkClient::Disconnect()
|
|
||||||
{
|
|
||||||
privateData->data->connection.Disconnect();
|
|
||||||
privateData->data->thread.Terminate();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool NetworkClient::IsConnected()
|
|
||||||
{
|
|
||||||
return privateData->data->connection.IsConnected();
|
|
||||||
}
|
|
||||||
|
|
||||||
void NetworkClient::Send(CustomProtocolObject& protocol)
|
|
||||||
{
|
|
||||||
this->privateData->Send(protocol.GetProtocol());
|
|
||||||
}
|
|
||||||
|
|
||||||
void NetworkClient::Send(CustomNetProtocol* protocol)
|
|
||||||
{
|
|
||||||
this->privateData->Send(protocol);
|
|
||||||
}
|
|
||||||
|
|
||||||
void NetworkClient::SetRecieverObject(RecieverObject recvObj, NetworkProtocolCallbackType type)
|
|
||||||
{
|
|
||||||
if (type == NetworkProtocolCallbackType_Unknown) return; //It should probably still be set even if it is unknown.
|
|
||||||
|
|
||||||
privateData->data->recvObjMutex.lock();
|
|
||||||
privateData->data->recvObj = recvObj;
|
|
||||||
privateData->data->callbackType = type;
|
|
||||||
privateData->data->recvObjMutex.unlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool NetworkClient::operator ==(const NetworkClient& obj)
|
bool NetworkClient::operator ==(const NetworkClient& obj)
|
||||||
{
|
{
|
||||||
return (this->privateData->data->ID == obj.privateData->data->ID);
|
return (this->privateData->ID == obj.privateData->ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NetworkClient::operator ==(const int& ID)
|
bool NetworkClient::operator ==(const int& ID)
|
||||||
{
|
{
|
||||||
return this->privateData->data->ID == ID;
|
return this->privateData->ID == ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
void NetworkClient::Update()
|
||||||
|
{
|
||||||
|
while (!this->privateData->recieveQueue.IsEmpty())
|
||||||
|
{
|
||||||
|
NetEvent<NetworkClient*, ClientEventArgs> temp = this->privateData->recieveQueue.Pop();
|
||||||
|
|
||||||
|
this->DataRecieved(temp);
|
||||||
|
|
||||||
|
//--------- Deprecate ---------
|
||||||
|
this->NetworkCallback(temp.args.data.protocol);
|
||||||
|
//------------------------------
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool NetworkClient::Connect(ConnectionInfo& socket)
|
||||||
|
{
|
||||||
|
if(this->IsConnected()) return true;
|
||||||
|
if(this->privateData) return false;
|
||||||
|
if(!this->privateData) this->privateData = new PrivateData();
|
||||||
|
|
||||||
|
int result = this->privateData->connection.Connect(socket, false);
|
||||||
|
|
||||||
|
//Connect has succeeded
|
||||||
|
if(result != 0) return false;
|
||||||
|
|
||||||
|
this->privateData->parent = this;
|
||||||
|
this->privateData->thread.Start();
|
||||||
|
|
||||||
|
//Connect has failed
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool NetworkClient::Connect(unsigned short port, const char serverIP[])
|
||||||
|
{
|
||||||
|
if(this->IsConnected()) return false;
|
||||||
|
if(this->privateData) return false;
|
||||||
|
if(!this->privateData) this->privateData = new PrivateData();
|
||||||
|
|
||||||
|
int result = this->privateData->connection.Connect(port, serverIP, false);
|
||||||
|
|
||||||
|
//Connect has succeeded
|
||||||
|
if(result != 0) return false;
|
||||||
|
|
||||||
|
this->privateData->parent = this;
|
||||||
|
this->privateData->thread.Start();
|
||||||
|
|
||||||
|
//Connect has failed
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void NetworkClient::Disconnect()
|
||||||
|
{
|
||||||
|
privateData->connection.Disconnect();
|
||||||
|
privateData->thread.Terminate();
|
||||||
|
}
|
||||||
|
|
||||||
|
void NetworkClient::Send(CustomProtocolObject& protocol)
|
||||||
|
{
|
||||||
|
this->privateData->sendQueue.Push(*protocol.GetProtocol());
|
||||||
|
}
|
||||||
|
|
||||||
|
void NetworkClient::Send(CustomNetProtocol* protocol)
|
||||||
|
{
|
||||||
|
this->privateData->sendQueue.Push(*protocol);
|
||||||
|
}
|
||||||
|
|
||||||
|
void NetworkClient::SetOwner(NetworkSession* owner)
|
||||||
|
{
|
||||||
|
this->privateData->owner = owner;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool NetworkClient::IsConnected()
|
||||||
|
{
|
||||||
|
if(!this->privateData) return false;
|
||||||
|
return privateData->connection.IsConnected();
|
||||||
}
|
}
|
||||||
|
|
||||||
int NetworkClient::GetID() const
|
int NetworkClient::GetID() const
|
||||||
{
|
{
|
||||||
return this->privateData->data->ID;
|
return this->privateData->ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
void NetworkClient::DataRecieved(NetEvent<NetworkClient*, ClientEventArgs> e)
|
||||||
|
{
|
||||||
|
if(this->privateData->owner)
|
||||||
|
{
|
||||||
|
this->privateData->owner->ClientEventCallback(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void NetworkClient::NetworkCallback(Oyster::Network::CustomNetProtocol& p)
|
||||||
|
{}
|
||||||
|
|
||||||
|
std::string NetworkClient::GetIpAddress()
|
||||||
|
{
|
||||||
|
return this->privateData->connection.GetIpAddress();
|
||||||
}
|
}
|
|
@ -1,59 +1,116 @@
|
||||||
#ifndef NETWORK_API_NETWORK_CLIENT_H
|
#ifndef NETWORK_API_NETWORK_CLIENT_H
|
||||||
#define NETWORK_API_NETWORK_CLIENT_H
|
#define NETWORK_API_NETWORK_CLIENT_H
|
||||||
|
|
||||||
/////////////////////////////////////
|
//////////////////////////////////////
|
||||||
// Created by Pontus Fransson 2013 //
|
// Created by Pontus Fransson 2013 //
|
||||||
/////////////////////////////////////
|
// Modified by Dennis Andersen 2014 //
|
||||||
|
//////////////////////////////////////
|
||||||
|
|
||||||
#ifdef CUSTOM_NET_PROTOCOL_EXPORT
|
#include "CustomNetProtocol.h"
|
||||||
#define NET_PROTOCOL_EXPORT __declspec(dllexport)
|
#include "NetworkServerEventStruct.h"
|
||||||
#else
|
#include "NetworkAPI_Preprocessor.h"
|
||||||
#define NET_PROTOCOL_EXPORT __declspec(dllimport)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "NetworkCallbackHelper.h"
|
|
||||||
//#include <vld.h>
|
|
||||||
|
|
||||||
namespace Oyster
|
namespace Oyster
|
||||||
{
|
{
|
||||||
namespace Network
|
namespace Network
|
||||||
{
|
{
|
||||||
|
class NetworkSession;
|
||||||
|
struct ConnectionInfo;
|
||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
struct CustomProtocolObject;
|
class NET_API_EXPORT NetworkClient
|
||||||
class NET_PROTOCOL_EXPORT NetworkClient
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
NetworkClient();
|
struct ClientEventArgs
|
||||||
NetworkClient(unsigned int socket);
|
{
|
||||||
NetworkClient(RecieverObject recvObj, NetworkProtocolCallbackType type);
|
enum EventType
|
||||||
NetworkClient(RecieverObject recvObj, NetworkProtocolCallbackType type, unsigned int socket);
|
{
|
||||||
NetworkClient(const NetworkClient& obj);
|
EventType_ProtocolFailedToRecieve, // No data
|
||||||
|
EventType_ProtocolFailedToSend, // Data in data.protocol
|
||||||
|
EventType_ProtocolRecieved, // Data in data.protocol
|
||||||
|
EventType_Disconnect, // No data
|
||||||
|
} type;
|
||||||
|
|
||||||
NetworkClient& operator =(const NetworkClient& obj);
|
union EventData
|
||||||
|
{
|
||||||
|
struct { Oyster::Network::CustomNetProtocol protocol; };
|
||||||
|
void * nothing;
|
||||||
|
} data;
|
||||||
|
};
|
||||||
|
typedef void(*ClientEventFunction)(NetEvent<NetworkClient*, ClientEventArgs> e);
|
||||||
|
|
||||||
|
public:
|
||||||
|
NetworkClient();
|
||||||
virtual ~NetworkClient();
|
virtual ~NetworkClient();
|
||||||
|
|
||||||
bool Connect(unsigned short port, const char serverIP[]);
|
|
||||||
void Disconnect();
|
|
||||||
|
|
||||||
bool IsConnected();
|
|
||||||
|
|
||||||
//Adds the protocol to the queue of protocols to be sent.
|
|
||||||
void Send(CustomProtocolObject& protocol);
|
|
||||||
void Send(CustomNetProtocol* protocol);
|
|
||||||
|
|
||||||
void SetRecieverObject(RecieverObject recvObj, NetworkProtocolCallbackType type);
|
|
||||||
|
|
||||||
//Compares the internal ID.
|
|
||||||
bool operator ==(const NetworkClient& obj);
|
bool operator ==(const NetworkClient& obj);
|
||||||
bool operator ==(const int& ID);
|
bool operator ==(const int& ID);
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void Update();
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
bool Connect(ConnectionInfo& data);
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
bool Connect(unsigned short port, const char serverIP[]);
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void Disconnect();
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void Send(CustomProtocolObject& protocol);
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void Send(CustomNetProtocol* protocol);
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void SetOwner(NetworkSession* owner);
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
bool IsConnected();
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
int GetID() const;
|
int GetID() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
virtual void DataRecieved(NetEvent<NetworkClient*, ClientEventArgs> e);
|
||||||
|
|
||||||
|
/** ! Deprecate !
|
||||||
|
* Do not use this furthermore, instead use void DataRecieved(NetEvent<NetworkClient*, ClientEventArgs> e);
|
||||||
|
* @see DataRecieved
|
||||||
|
*/
|
||||||
|
virtual void NetworkCallback(Oyster::Network::CustomNetProtocol& p);
|
||||||
|
|
||||||
|
virtual std::string GetIpAddress();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
NetworkClient(const NetworkClient& obj);
|
||||||
|
NetworkClient& operator =(const NetworkClient& obj);
|
||||||
|
|
||||||
struct PrivateData;
|
struct PrivateData;
|
||||||
PrivateData* privateData;
|
PrivateData* privateData;
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,11 +9,14 @@
|
||||||
#include "../NetworkDependencies/PostBox.h"
|
#include "../NetworkDependencies/PostBox.h"
|
||||||
#include "../NetworkDependencies/WinsockFunctions.h"
|
#include "../NetworkDependencies/WinsockFunctions.h"
|
||||||
|
|
||||||
#include "../../Misc/Utilities.h"
|
#include "Utilities.h"
|
||||||
#include "../../Misc/Thread/OysterThread.h"
|
#include "Thread/OysterThread.h"
|
||||||
|
|
||||||
|
#ifndef _DEBUG
|
||||||
|
#include <winsock2.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
using namespace Oyster::Network;
|
using namespace Oyster::Network;
|
||||||
using namespace ::Server;
|
|
||||||
using namespace Utility::DynamicMemory;
|
using namespace Utility::DynamicMemory;
|
||||||
using namespace Oyster::Thread;
|
using namespace Oyster::Thread;
|
||||||
|
|
||||||
|
@ -21,148 +24,89 @@ using namespace Oyster::Thread;
|
||||||
PrivateData
|
PrivateData
|
||||||
*************************************/
|
*************************************/
|
||||||
|
|
||||||
|
void Broadcast()
|
||||||
|
{
|
||||||
|
char pkt[4];
|
||||||
|
size_t pkt_length = 4;
|
||||||
|
sockaddr_in dest;
|
||||||
|
sockaddr_in local;
|
||||||
|
WSAData data;
|
||||||
|
WSAStartup( MAKEWORD( 2, 2 ), &data );
|
||||||
|
|
||||||
|
local.sin_family = AF_INET;
|
||||||
|
local.sin_addr.s_addr = inet_addr( "127.0.0.1" );
|
||||||
|
local.sin_port = 15151; // choose any
|
||||||
|
|
||||||
|
dest.sin_family = AF_INET;
|
||||||
|
dest.sin_port = htons( 15151 );
|
||||||
|
|
||||||
|
// create the socket
|
||||||
|
SOCKET s = socket( AF_INET, SOCK_DGRAM, IPPROTO_UDP );
|
||||||
|
// bind to the local address
|
||||||
|
bind( s, (sockaddr *)&local, sizeof(local) );
|
||||||
|
|
||||||
|
std::string addr;
|
||||||
|
for (int i = 0; i < 256; i++)
|
||||||
|
{
|
||||||
|
addr = "192.168.0.";
|
||||||
|
char buff[5];
|
||||||
|
_itoa_s<5>(i, buff, 10);
|
||||||
|
|
||||||
|
addr.append(buff);
|
||||||
|
dest.sin_addr.s_addr = inet_addr( addr.c_str() );
|
||||||
|
// send the pkt
|
||||||
|
int ret = sendto( s, pkt, pkt_length, 0, (sockaddr *)&dest, sizeof(dest) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
struct NetworkServer::PrivateData : public IThreadObject
|
struct NetworkServer::PrivateData : public IThreadObject
|
||||||
{
|
{
|
||||||
PrivateData();
|
public:
|
||||||
~PrivateData();
|
PrivateData()
|
||||||
|
: listener(0)
|
||||||
bool Init(INIT_DESC& initDesc);
|
, mainSession(0)
|
||||||
bool Start();
|
, isInitiated(0)
|
||||||
void Stop();
|
, isReleased(0)
|
||||||
void Shutdown();
|
, isRunning(0)
|
||||||
|
, port(-1)
|
||||||
void CheckForNewClient();
|
{ }
|
||||||
|
~PrivateData()
|
||||||
|
{ }
|
||||||
|
|
||||||
bool DoWork();
|
bool DoWork();
|
||||||
|
|
||||||
//
|
public:
|
||||||
IListener* listener;
|
Listener* listener;
|
||||||
INIT_DESC initDesc;
|
PostBox<ConnectionInfo> postBox; //Postbox for new clients
|
||||||
bool started;
|
OysterThread thread; //Server thread
|
||||||
|
NetworkSession *mainSession;
|
||||||
//Postbox for new clients
|
Utility::Container::ThreadSafeQueue<SmartPointer<NetworkClient>> clientQueue;
|
||||||
PostBox<int> postBox;
|
|
||||||
|
|
||||||
//Server thread
|
|
||||||
OysterThread thread;
|
|
||||||
|
|
||||||
|
bool isInitiated;
|
||||||
|
bool isReleased;
|
||||||
|
bool isRunning;
|
||||||
|
int port;
|
||||||
};
|
};
|
||||||
|
|
||||||
NetworkServer::PrivateData::PrivateData()
|
|
||||||
{
|
|
||||||
listener = 0;
|
|
||||||
started = false;
|
|
||||||
//postBox = new PostBox<int>;
|
|
||||||
}
|
|
||||||
|
|
||||||
NetworkServer::PrivateData::~PrivateData()
|
|
||||||
{
|
|
||||||
Shutdown();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool NetworkServer::PrivateData::Init(INIT_DESC& initDesc)
|
|
||||||
{
|
|
||||||
//Check if it's a valid port
|
|
||||||
if(initDesc.port == 0)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!InitWinSock())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
this->initDesc = initDesc;
|
|
||||||
|
|
||||||
//Initiate listener
|
|
||||||
listener = new Listener(&postBox);
|
|
||||||
if(!((Listener*)listener)->Init(this->initDesc.port, false))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(thread.Create(this, false) == OYSTER_THREAD_ERROR_FAILED)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool NetworkServer::PrivateData::Start()
|
|
||||||
{
|
|
||||||
//Start listener
|
|
||||||
if(!((Listener*)listener)->Start())
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
started = true;
|
|
||||||
|
|
||||||
if(thread.Start() == OYSTER_THREAD_ERROR_FAILED)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void NetworkServer::PrivateData::Stop()
|
|
||||||
{
|
|
||||||
if(listener)
|
|
||||||
{
|
|
||||||
((Listener*)listener)->Stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
started = false;
|
|
||||||
|
|
||||||
thread.Stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
void NetworkServer::PrivateData::Shutdown()
|
|
||||||
{
|
|
||||||
if(listener)
|
|
||||||
{
|
|
||||||
listener->Shutdown();
|
|
||||||
delete listener;
|
|
||||||
listener = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
started = false;
|
|
||||||
thread.Terminate();
|
|
||||||
|
|
||||||
ShutdownWinSock();
|
|
||||||
}
|
|
||||||
|
|
||||||
//Checks for new clients and sends them to the proc function.
|
|
||||||
void NetworkServer::PrivateData::CheckForNewClient()
|
|
||||||
{
|
|
||||||
if(postBox.IsFull())
|
|
||||||
{
|
|
||||||
int clientSocketNum = postBox.FetchMessage();
|
|
||||||
|
|
||||||
//Safety check that is probably not needed.
|
|
||||||
if(clientSocketNum == -1)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Create client and Proc function if the pointer is not NULL
|
|
||||||
if(initDesc.callbackType == NetworkClientCallbackType_Function)
|
|
||||||
{
|
|
||||||
Oyster::Network::NetworkClient *client = new Oyster::Network::NetworkClient(clientSocketNum);
|
|
||||||
initDesc.recvObj.clientConnectFnc(client);
|
|
||||||
}
|
|
||||||
else if(initDesc.callbackType == NetworkClientCallbackType_Object)
|
|
||||||
{
|
|
||||||
Oyster::Network::NetworkClient *client = new Oyster::Network::NetworkClient(clientSocketNum);
|
|
||||||
initDesc.recvObj.clientConnectObject->NetworkCallback(client);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool NetworkServer::PrivateData::DoWork()
|
bool NetworkServer::PrivateData::DoWork()
|
||||||
{
|
{
|
||||||
CheckForNewClient();
|
//Broadcast();
|
||||||
|
|
||||||
|
/** Check for new clients **/
|
||||||
|
if(postBox.IsFull())
|
||||||
|
{
|
||||||
|
ConnectionInfo clientSocketNum = postBox.FetchMessage();
|
||||||
|
|
||||||
|
if(clientSocketNum.socket == -1)
|
||||||
|
{
|
||||||
|
//Something went wrong somewhere... do we care?
|
||||||
|
}
|
||||||
|
|
||||||
|
SmartPointer<NetworkClient> client(new NetworkClient());
|
||||||
|
client->Connect(clientSocketNum);
|
||||||
|
|
||||||
|
this->clientQueue.Push(client);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -173,48 +117,172 @@ bool NetworkServer::PrivateData::DoWork()
|
||||||
|
|
||||||
NetworkServer::NetworkServer()
|
NetworkServer::NetworkServer()
|
||||||
{
|
{
|
||||||
privateData = new PrivateData();
|
this->privateData = new PrivateData();
|
||||||
|
}
|
||||||
|
NetworkServer::NetworkServer(const NetworkServer& obj)
|
||||||
|
{
|
||||||
|
delete this->privateData;
|
||||||
|
this->privateData = new PrivateData(*obj.privateData);
|
||||||
|
}
|
||||||
|
const NetworkServer& NetworkServer::operator=(const NetworkServer& obj)
|
||||||
|
{
|
||||||
|
delete this->privateData;
|
||||||
|
this->privateData = new PrivateData(*obj.privateData);
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
NetworkServer::~NetworkServer()
|
NetworkServer::~NetworkServer()
|
||||||
{
|
{
|
||||||
if(privateData)
|
if(this->privateData)
|
||||||
{
|
{
|
||||||
delete privateData;
|
delete this->privateData;
|
||||||
|
this->privateData = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NetworkServer::Init(INIT_DESC& initDesc)
|
NetworkServer::ServerReturnCode NetworkServer::Init(const int& port, NetworkSession const* mainSession)
|
||||||
{
|
{
|
||||||
if(!privateData->Init(initDesc))
|
this->privateData->mainSession = const_cast<NetworkSession*>(mainSession);
|
||||||
|
//Check if it's a valid port
|
||||||
|
if(port == 0 || port == -1)
|
||||||
{
|
{
|
||||||
return false;
|
return NetworkServer::ServerReturnCode_Error;
|
||||||
|
}
|
||||||
|
else if(this->privateData->port != 0 && this->privateData->port != -1)
|
||||||
|
{
|
||||||
|
return NetworkServer::ServerReturnCode_Error;
|
||||||
|
}
|
||||||
|
if(!InitWinSock())
|
||||||
|
{
|
||||||
|
return NetworkServer::ServerReturnCode_Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
//Initiate listener
|
||||||
|
this->privateData->listener = new Listener(&this->privateData->postBox);
|
||||||
|
if(!this->privateData->listener->Init(port, false))
|
||||||
|
{
|
||||||
|
return NetworkServer::ServerReturnCode_Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NetworkServer::Start()
|
if(this->privateData->thread.Create(this->privateData, false) == OYSTER_THREAD_ERROR_FAILED)
|
||||||
{
|
{
|
||||||
if(!privateData->Start())
|
return NetworkServer::ServerReturnCode_Error;
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
this->privateData->isInitiated = true;
|
||||||
|
this->privateData->isReleased = false;
|
||||||
|
return NetworkServer::ServerReturnCode_Sucess;
|
||||||
|
}
|
||||||
|
|
||||||
|
NetworkServer::ServerReturnCode NetworkServer::Start()
|
||||||
|
{
|
||||||
|
//Start listener
|
||||||
|
if(!this->privateData->listener->Start())
|
||||||
|
{
|
||||||
|
return NetworkServer::ServerReturnCode_Error;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(this->privateData->thread.Start() == OYSTER_THREAD_ERROR_FAILED)
|
||||||
|
{
|
||||||
|
return NetworkServer::ServerReturnCode_Error;
|
||||||
|
}
|
||||||
|
|
||||||
|
this->privateData->isRunning = true;
|
||||||
|
return NetworkServer::ServerReturnCode_Sucess;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetworkServer::Stop()
|
void NetworkServer::Stop()
|
||||||
{
|
{
|
||||||
privateData->Stop();
|
if(this->privateData->listener)
|
||||||
|
{
|
||||||
|
this->privateData->listener->Stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
this->privateData->thread.Stop();
|
||||||
|
|
||||||
|
this->privateData->isRunning = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetworkServer::Shutdown()
|
void NetworkServer::Shutdown()
|
||||||
{
|
{
|
||||||
privateData->Shutdown();
|
if(this->privateData->mainSession)
|
||||||
|
{
|
||||||
|
this->privateData->mainSession->CloseSession(true);
|
||||||
|
}
|
||||||
|
if(this->privateData->listener)
|
||||||
|
{
|
||||||
|
this->privateData->listener->Shutdown();
|
||||||
|
delete this->privateData->listener;
|
||||||
|
this->privateData->listener = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
this->privateData->thread.Terminate();
|
||||||
|
|
||||||
|
ShutdownWinSock();
|
||||||
|
|
||||||
|
this->privateData->isRunning = false;
|
||||||
|
this->privateData->mainSession = 0;
|
||||||
|
this->privateData->isReleased = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int NetworkServer::ProcessConnectedClients()
|
||||||
|
{
|
||||||
|
int c = 0;
|
||||||
|
while(!this->privateData->clientQueue.IsEmpty())
|
||||||
|
{
|
||||||
|
if(this->privateData->mainSession)
|
||||||
|
{
|
||||||
|
this->privateData->mainSession->ClientConnectedEvent(this->privateData->clientQueue.Pop());
|
||||||
|
c++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//Clients have nowhere to go?
|
||||||
|
this->privateData->clientQueue.Pop()->Disconnect();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
void NetworkServer::SetSession(NetworkSession const* mainSession)
|
||||||
|
{
|
||||||
|
this->privateData->mainSession = const_cast<NetworkSession*>(mainSession);
|
||||||
|
}
|
||||||
|
|
||||||
|
NetworkSession const* NetworkServer::GetMainSession()
|
||||||
|
{
|
||||||
|
return this->privateData->mainSession;
|
||||||
|
}
|
||||||
|
|
||||||
|
NetworkSession const* NetworkServer::ReleaseMainSession()
|
||||||
|
{
|
||||||
|
NetworkSession const * temp;
|
||||||
|
temp = this->privateData->mainSession;
|
||||||
|
this->privateData->mainSession = 0;
|
||||||
|
return temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NetworkServer::IsStarted() const
|
bool NetworkServer::IsStarted() const
|
||||||
{
|
{
|
||||||
return privateData->started;
|
return this->privateData->isRunning;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string NetworkServer::GetLanAddress()
|
||||||
|
{
|
||||||
|
std::string szLocalIP;
|
||||||
|
char szHostName[255];
|
||||||
|
struct hostent *host_entry;
|
||||||
|
|
||||||
|
gethostname(szHostName, 255);
|
||||||
|
|
||||||
|
host_entry = gethostbyname(szHostName);
|
||||||
|
char* temp = inet_ntoa (*(struct in_addr *)*host_entry->h_addr_list);
|
||||||
|
|
||||||
|
char buff[255];
|
||||||
|
strcpy_s(buff, temp);
|
||||||
|
szLocalIP = buff;
|
||||||
|
return szLocalIP;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,18 +1,15 @@
|
||||||
#ifndef NETWORK_API_NETWORK_SERVER_H
|
#ifndef NETWORK_API_NETWORK_SERVER_H
|
||||||
#define NETWORK_API_NETWORK_SERVER_H
|
#define NETWORK_API_NETWORK_SERVER_H
|
||||||
|
|
||||||
/////////////////////////////////////
|
//////////////////////////////////////
|
||||||
// Created by Pontus Fransson 2013 //
|
// Created by Pontus Fransson 2013 //
|
||||||
/////////////////////////////////////
|
// Modified by Dennis Andersen 2014 //
|
||||||
|
//////////////////////////////////////
|
||||||
|
|
||||||
#ifdef CUSTOM_NET_PROTOCOL_EXPORT
|
|
||||||
#define NET_PROTOCOL_EXPORT __declspec(dllexport)
|
|
||||||
#else
|
|
||||||
#define NET_PROTOCOL_EXPORT __declspec(dllimport)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
#include "NetworkAPI_Preprocessor.h"
|
||||||
#include "NetworkClient.h"
|
#include "NetworkClient.h"
|
||||||
#include "NetworkCallbackHelper.h"
|
#include "NetworkSession.h"
|
||||||
#include <vld.h>
|
#include <vld.h>
|
||||||
|
|
||||||
namespace Oyster
|
namespace Oyster
|
||||||
|
@ -21,27 +18,72 @@ namespace Oyster
|
||||||
{
|
{
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
class NET_PROTOCOL_EXPORT NetworkServer
|
class NET_API_EXPORT NetworkServer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
struct INIT_DESC
|
enum ServerReturnCode
|
||||||
{
|
{
|
||||||
unsigned short port; //Port the server should be accepting clients on.
|
ServerReturnCode_Error,
|
||||||
|
ServerReturnCode_Sucess
|
||||||
NetworkClientCallbackType callbackType; //The recieverObject type. Function or object.
|
|
||||||
RecieverObject recvObj; //The functions that is called when a new client has connected.
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public:
|
||||||
NetworkServer();
|
NetworkServer();
|
||||||
|
NetworkServer(const NetworkServer&);
|
||||||
|
const NetworkServer& operator=(const NetworkServer&);
|
||||||
virtual ~NetworkServer();
|
virtual ~NetworkServer();
|
||||||
|
|
||||||
bool Init(INIT_DESC& initDesc);
|
|
||||||
bool Start();
|
/** Creates a server that clients can connect to
|
||||||
|
* @param port The port the server will be listening for clients.
|
||||||
|
* @param mainSession The main session the server will send connected clients to.
|
||||||
|
* @return The server returncode
|
||||||
|
*/
|
||||||
|
ServerReturnCode Init(const int& port, NetworkSession const* mainSession);
|
||||||
|
|
||||||
|
/** Starts the server allowing clients to connect
|
||||||
|
* @return The server returncode
|
||||||
|
*/
|
||||||
|
ServerReturnCode Start();
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
void Stop();
|
void Stop();
|
||||||
|
|
||||||
|
/** Shutdown the server and return all resources.
|
||||||
|
*/
|
||||||
void Shutdown();
|
void Shutdown();
|
||||||
|
|
||||||
|
/** Parses asynchronous connected clients.
|
||||||
|
*/
|
||||||
|
int ProcessConnectedClients();
|
||||||
|
|
||||||
|
/** Set the main session connected clients will enter when connected to server.
|
||||||
|
* @param mainSession The session to connect as main server session.
|
||||||
|
*/
|
||||||
|
void SetSession(NetworkSession const* mainSession);
|
||||||
|
|
||||||
|
/** Get the main session connected with the server
|
||||||
|
* @return Returns the main session
|
||||||
|
*/
|
||||||
|
NetworkSession const* GetMainSession();
|
||||||
|
|
||||||
|
/** Sets the main session to NULL and returns it
|
||||||
|
* @return Returns the main session
|
||||||
|
*/
|
||||||
|
NetworkSession const* ReleaseMainSession();
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
bool IsStarted() const;
|
bool IsStarted() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
std::string GetLanAddress();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct PrivateData;
|
struct PrivateData;
|
||||||
PrivateData* privateData;
|
PrivateData* privateData;
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
#ifndef NETWORK_API_SERVEREVENT_H
|
||||||
|
#define NETWORK_API_SERVEREVENT_H
|
||||||
|
|
||||||
|
namespace Oyster
|
||||||
|
{
|
||||||
|
namespace Network
|
||||||
|
{
|
||||||
|
template <typename Sender, typename Args>
|
||||||
|
struct NetEvent
|
||||||
|
{
|
||||||
|
Sender sender;
|
||||||
|
Args args;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // !SERVERDEPENDENCIES_SERVEREVENT_H
|
|
@ -0,0 +1,231 @@
|
||||||
|
/////////////////////////////////////////////////////////////////////
|
||||||
|
// Created by [Dennis Andersen] [2013]
|
||||||
|
/////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "NetworkSession.h"
|
||||||
|
#include "..\..\Misc\Utilities.h"
|
||||||
|
#include "..\..\Misc\DynamicArray.h"
|
||||||
|
#include "..\..\Misc\GID.h"
|
||||||
|
#include "CustomNetProtocol.h"
|
||||||
|
#include <vector>
|
||||||
|
#include <mutex>
|
||||||
|
|
||||||
|
using namespace Utility::DynamicMemory;
|
||||||
|
using namespace Oyster::Network;
|
||||||
|
|
||||||
|
|
||||||
|
struct NetworkSession::PrivateSessionData
|
||||||
|
{
|
||||||
|
Utility::DynamicMemory::DynamicArray<NetClient> clients;
|
||||||
|
NetworkClient::ClientEventFunction messageCallback;
|
||||||
|
std::mutex clientListLock;
|
||||||
|
NetworkSession* owner; //Where clients end up when session is closed.
|
||||||
|
int clientCount;
|
||||||
|
int id;
|
||||||
|
NetworkSession::PrivateSessionData()
|
||||||
|
: clientCount(0)
|
||||||
|
, owner(0)
|
||||||
|
, id(GID())
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
NetworkSession::NetworkSession()
|
||||||
|
: data(new PrivateSessionData())
|
||||||
|
{}
|
||||||
|
NetworkSession::NetworkSession(const NetworkSession& orig)
|
||||||
|
{
|
||||||
|
this->data->clients = orig.data->clients;
|
||||||
|
this->data->owner = orig.data->owner;
|
||||||
|
this->data->clientCount = orig.data->clientCount;
|
||||||
|
this->data->id = orig.data->id;
|
||||||
|
this->data->messageCallback = orig.data->messageCallback;
|
||||||
|
}
|
||||||
|
|
||||||
|
const NetworkSession& NetworkSession::operator=(const NetworkSession& orig)
|
||||||
|
{
|
||||||
|
this->data->clients = orig.data->clients;
|
||||||
|
this->data->owner = orig.data->owner;
|
||||||
|
this->data->clientCount = orig.data->clientCount;
|
||||||
|
this->data->id = orig.data->id;
|
||||||
|
this->data->messageCallback = orig.data->messageCallback;
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
NetworkSession::~NetworkSession()
|
||||||
|
{
|
||||||
|
this->data->clients.Clear();
|
||||||
|
this->data->clientCount = 0;
|
||||||
|
this->data->messageCallback = 0;
|
||||||
|
delete this->data;
|
||||||
|
this->data = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void NetworkSession::ProcessClients()
|
||||||
|
{
|
||||||
|
for (unsigned int i = 0; i < this->data->clients.Size(); i++)
|
||||||
|
{
|
||||||
|
if(this->data->clients[i]) this->data->clients[i]->Update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool NetworkSession::Attach(NetClient client)
|
||||||
|
{
|
||||||
|
this->data->clientListLock.lock();
|
||||||
|
|
||||||
|
int k = -1;
|
||||||
|
for (unsigned int i = 0; (k == -1) && i < this->data->clients.Size(); i++)
|
||||||
|
{
|
||||||
|
if(!this->data->clients[i]->IsConnected()) //TODO: Dont check connection status, check more general status..
|
||||||
|
k = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(k == -1)
|
||||||
|
{
|
||||||
|
this->data->clients.Push(client);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this->data->clients[k] = client;
|
||||||
|
}
|
||||||
|
|
||||||
|
this->data->clientCount++;
|
||||||
|
|
||||||
|
client->SetOwner(this);
|
||||||
|
this->data->clientListLock.unlock();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void NetworkSession::Detach()
|
||||||
|
{
|
||||||
|
if(this->data->owner)
|
||||||
|
{
|
||||||
|
for (unsigned int i = 0; i < this->data->clients.Size(); i++)
|
||||||
|
{
|
||||||
|
this->data->owner->Attach(this->data->clients[i]);
|
||||||
|
this->data->clients[i] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (unsigned int i = 0; i < this->data->clients.Size(); i++)
|
||||||
|
{
|
||||||
|
this->data->clients[i]->Disconnect();
|
||||||
|
this->data->clients[i] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
NetClient NetworkSession::Detach(const NetworkClient* client)
|
||||||
|
{
|
||||||
|
NetClient val;
|
||||||
|
|
||||||
|
this->data->clientListLock.lock();
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < this->data->clients.Size(); i++)
|
||||||
|
{
|
||||||
|
if(this->data->clients[i] && this->data->clients[0]->GetID() == client->GetID())
|
||||||
|
{
|
||||||
|
val = this->data->clients[i];
|
||||||
|
this->data->clients[i] = 0;
|
||||||
|
this->data->clientCount--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this->data->clientListLock.unlock();
|
||||||
|
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
NetClient NetworkSession::Detach(short ID)
|
||||||
|
{
|
||||||
|
NetClient val;
|
||||||
|
|
||||||
|
this->data->clientListLock.lock();
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < this->data->clients.Size(); i++)
|
||||||
|
{
|
||||||
|
if(this->data->clients[i] && this->data->clients[0]->GetID() == ID)
|
||||||
|
{
|
||||||
|
val = this->data->clients[i];
|
||||||
|
this->data->clients[i] = 0;
|
||||||
|
this->data->clientCount--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this->data->clientListLock.unlock();
|
||||||
|
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool NetworkSession::Send(Oyster::Network::CustomNetProtocol& protocol)
|
||||||
|
{
|
||||||
|
bool returnValue = false;
|
||||||
|
for (unsigned int i = 0; i < this->data->clients.Size(); i++)
|
||||||
|
{
|
||||||
|
if(this->data->clients[i])
|
||||||
|
{
|
||||||
|
this->data->clients[i]->Send(&protocol);
|
||||||
|
returnValue = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return returnValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool NetworkSession::Send(Oyster::Network::CustomNetProtocol& protocol, int ID)
|
||||||
|
{
|
||||||
|
for (unsigned int i = 0; i < this->data->clients.Size(); i++)
|
||||||
|
{
|
||||||
|
if(this->data->clients[i] && this->data->clients[i]->GetID() == ID)
|
||||||
|
{
|
||||||
|
this->data->clients[i]->Send(&protocol);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void NetworkSession::CloseSession(bool dissconnectClients)
|
||||||
|
{
|
||||||
|
this->data->clientListLock.lock();
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < this->data->clients.Size(); i++)
|
||||||
|
{
|
||||||
|
if(this->data->clients[i])
|
||||||
|
{
|
||||||
|
if(dissconnectClients) this->data->clients[i]->Disconnect();
|
||||||
|
else if(this->data->owner) this->data->owner->Attach(this->data->clients[i]);
|
||||||
|
else this->data->clients[i]->Disconnect(); //Idiot check, clients have to go somewhere..
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this->data->clients.Clear();
|
||||||
|
this->data->clientCount = 0;
|
||||||
|
|
||||||
|
this->data->clientListLock.unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
void NetworkSession::SetOwner(NetworkSession* owner)
|
||||||
|
{
|
||||||
|
this->data->owner = owner;
|
||||||
|
}
|
||||||
|
|
||||||
|
int NetworkSession::GetClientCount() const
|
||||||
|
{
|
||||||
|
int c = 0;
|
||||||
|
for (unsigned int i = 0; i < this->data->clients.Size(); i++)
|
||||||
|
{
|
||||||
|
if(this->data->clients[i]) c++;
|
||||||
|
}
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
void NetworkSession::ClientConnectedEvent(NetClient client)
|
||||||
|
{
|
||||||
|
this->Attach(client);
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,96 @@
|
||||||
|
/////////////////////////////////////////////////////////////////////
|
||||||
|
// Created by [Dennis Andersen] [2013]
|
||||||
|
/////////////////////////////////////////////////////////////////////
|
||||||
|
#ifndef NETWORK_API_NETWORK_SESSION_H
|
||||||
|
#define NETWORK_API_NETWORK_SESSION_H
|
||||||
|
|
||||||
|
//warning C4150: deletion of pointer to incomplete type, no destructor called
|
||||||
|
#pragma warning(disable : 4150)
|
||||||
|
|
||||||
|
#include "NetworkAPI_Preprocessor.h"
|
||||||
|
#include "NetworkServerEventStruct.h"
|
||||||
|
#include "NetworkClient.h"
|
||||||
|
#include "Utilities.h"
|
||||||
|
|
||||||
|
namespace Oyster
|
||||||
|
{
|
||||||
|
namespace Network
|
||||||
|
{
|
||||||
|
typedef Utility::DynamicMemory::SmartPointer<NetworkClient> NetClient;
|
||||||
|
class NET_API_EXPORT NetworkSession
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
NetworkSession();
|
||||||
|
NetworkSession(const NetworkSession& orig);
|
||||||
|
const NetworkSession& operator=(const NetworkSession& orig);
|
||||||
|
virtual~NetworkSession();
|
||||||
|
|
||||||
|
/** Parse session events such as protocols recieved etc.
|
||||||
|
*/
|
||||||
|
void ProcessClients();
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
virtual bool Attach(NetClient client);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Detaches all clients and sends them to owner.
|
||||||
|
* If no owner is set the clients is disconnected.
|
||||||
|
*/
|
||||||
|
virtual void Detach();
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
virtual NetClient Detach(const NetworkClient* client);
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
virtual NetClient Detach(short ID);
|
||||||
|
|
||||||
|
/** Send a message to all clients in this session
|
||||||
|
* @param message The message
|
||||||
|
*/
|
||||||
|
virtual bool Send(Oyster::Network::CustomNetProtocol& message);
|
||||||
|
|
||||||
|
/** Send a message to a specific client in this session
|
||||||
|
* @param message The message
|
||||||
|
*/
|
||||||
|
virtual bool Send(Oyster::Network::CustomNetProtocol& protocol, int ID);
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
virtual void CloseSession( bool dissconnectClients = false );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the owner that clients will be returned to.
|
||||||
|
* @param owner If owner is NULL, clients will be disconnected when session is over.
|
||||||
|
*/
|
||||||
|
virtual void SetOwner(NetworkSession* owner);
|
||||||
|
|
||||||
|
/** Get the number of clients active in this session
|
||||||
|
* @return The client count
|
||||||
|
*/
|
||||||
|
int GetClientCount() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
virtual void ClientConnectedEvent(NetClient client);
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
virtual void ClientEventCallback(NetEvent<NetworkClient*, NetworkClient::ClientEventArgs> e) = 0;
|
||||||
|
|
||||||
|
private:
|
||||||
|
struct PrivateSessionData;
|
||||||
|
PrivateSessionData* data;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}//End namespace DanBias
|
||||||
|
|
||||||
|
#endif // !DANBIASSERVER_NETWORK_SESSION_H
|
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
#include "CustomNetProtocol.h"
|
#include "CustomNetProtocol.h"
|
||||||
|
|
||||||
|
#include "../../Misc/Utilities.h"
|
||||||
#include "../NetworkDependencies/Messages/MessageHeader.h"
|
#include "../NetworkDependencies/Messages/MessageHeader.h"
|
||||||
#include "../NetworkDependencies/OysterByte.h"
|
#include "../NetworkDependencies/OysterByte.h"
|
||||||
|
|
||||||
|
@ -17,6 +18,7 @@ using namespace std;
|
||||||
struct MyCastingStruct
|
struct MyCastingStruct
|
||||||
{
|
{
|
||||||
std::map<int, NetAttributeContainer> attributes;
|
std::map<int, NetAttributeContainer> attributes;
|
||||||
|
Utility::DynamicMemory::ReferenceCount *c;
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: Check if the package has been packed correctly.
|
// TODO: Check if the package has been packed correctly.
|
||||||
|
|
|
@ -27,13 +27,7 @@
|
||||||
"100F"
|
"100F"
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef CUSTOM_NET_PROTOCOL_EXPORT
|
#include "NetworkAPI_Preprocessor.h"
|
||||||
#define NET_PROTOCOL_EXPORT __declspec(dllexport)
|
|
||||||
#else
|
|
||||||
#define NET_PROTOCOL_EXPORT __declspec(dllimport)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "../../Misc/Utilities.h"
|
|
||||||
|
|
||||||
namespace Oyster
|
namespace Oyster
|
||||||
{
|
{
|
||||||
|
@ -43,7 +37,8 @@ namespace Oyster
|
||||||
{
|
{
|
||||||
class OysterByte;
|
class OysterByte;
|
||||||
class CustomNetProtocol;
|
class CustomNetProtocol;
|
||||||
class NET_PROTOCOL_EXPORT Translator
|
|
||||||
|
class NET_API_EXPORT Translator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Translator ();
|
Translator ();
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "Connection.h"
|
#include "Connection.h"
|
||||||
|
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
|
#include <WS2tcpip.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
@ -40,8 +41,23 @@ Connection::~Connection()
|
||||||
CloseSocket( this->socket );
|
CloseSocket( this->socket );
|
||||||
}
|
}
|
||||||
|
|
||||||
int Connection::Connect(unsigned short port , const char serverName[])
|
int Connection::Connect(ConnectionInfo info, bool blocking)
|
||||||
{
|
{
|
||||||
|
this->addr = info.addr;
|
||||||
|
this->socket = info.socket;
|
||||||
|
this->stillSending = true;
|
||||||
|
this->closed = false;
|
||||||
|
|
||||||
|
|
||||||
|
SetBlockingMode(blocking);
|
||||||
|
//connection succesfull!
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Connection::Connect(unsigned short port , const char serverName[], bool blocking)
|
||||||
|
{
|
||||||
|
if(this->socket == -1 || this->socket == 0) InitiateSocket();
|
||||||
|
|
||||||
struct hostent *hostEnt;
|
struct hostent *hostEnt;
|
||||||
if((hostEnt = gethostbyname(serverName)) == NULL)
|
if((hostEnt = gethostbyname(serverName)) == NULL)
|
||||||
{
|
{
|
||||||
|
@ -61,6 +77,8 @@ int Connection::Connect(unsigned short port , const char serverName[])
|
||||||
closed = false;
|
closed = false;
|
||||||
stillSending = true;
|
stillSending = true;
|
||||||
|
|
||||||
|
SetBlockingMode(blocking);
|
||||||
|
|
||||||
//connection succesfull!
|
//connection succesfull!
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -152,17 +170,24 @@ int Connection::Recieve(OysterByte &bytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
//Listen will only return the correct socket or -1 for failure.
|
//Listen will only return the correct socket or -1 for failure.
|
||||||
int Connection::Listen()
|
ConnectionInfo Connection::Listen()
|
||||||
{
|
{
|
||||||
if(this->closed) return -1;
|
ConnectionInfo val = { 0 };
|
||||||
|
if(this->closed) return val;
|
||||||
|
|
||||||
int clientSocket;
|
SOCKADDR_IN client_info = { 0 };
|
||||||
if((clientSocket = (int)accept(this->socket, NULL, NULL)) == INVALID_SOCKET)
|
int addrsize = sizeof(client_info);
|
||||||
|
|
||||||
|
if((val.socket = (int)accept(this->socket, (struct sockaddr*)&client_info, &addrsize)) == INVALID_SOCKET)
|
||||||
{
|
{
|
||||||
return (int)INVALID_SOCKET;//WSAGetLastError();
|
val.socket = WSAGetLastError();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
val.addr = inet_ntoa(client_info.sin_addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
return clientSocket;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Connection::IsSending()
|
bool Connection::IsSending()
|
||||||
|
@ -198,6 +223,12 @@ int Connection::SetBlockingMode(bool blocking)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
std::string Connection::GetIpAddress()
|
||||||
|
{
|
||||||
|
return this->addr;
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////////////////
|
///////////////////////////////////////
|
||||||
//Private functions
|
//Private functions
|
||||||
///////////////////////////////////////
|
///////////////////////////////////////
|
||||||
|
|
|
@ -14,7 +14,6 @@ namespace Oyster
|
||||||
{
|
{
|
||||||
class Connection : public IConnection
|
class Connection : public IConnection
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Connection();
|
Connection();
|
||||||
Connection( int socket );
|
Connection( int socket );
|
||||||
|
@ -27,9 +26,10 @@ namespace Oyster
|
||||||
virtual int Recieve( OysterByte &bytes );
|
virtual int Recieve( OysterByte &bytes );
|
||||||
|
|
||||||
virtual int Disconnect();
|
virtual int Disconnect();
|
||||||
virtual int Connect( unsigned short port , const char serverName[] );
|
virtual int Connect(ConnectionInfo info, bool blocking = false);
|
||||||
|
virtual int Connect(unsigned short port , const char serverName[], bool blocking = false);
|
||||||
|
|
||||||
virtual int Listen();
|
virtual ConnectionInfo Listen();
|
||||||
|
|
||||||
bool IsSending();
|
bool IsSending();
|
||||||
bool IsConnected();
|
bool IsConnected();
|
||||||
|
@ -37,6 +37,8 @@ namespace Oyster
|
||||||
//Setting the socket to blocking/non-blocking mode.
|
//Setting the socket to blocking/non-blocking mode.
|
||||||
int SetBlockingMode( bool blocking );
|
int SetBlockingMode( bool blocking );
|
||||||
|
|
||||||
|
std::string GetIpAddress();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int InitiateSocket();
|
int InitiateSocket();
|
||||||
|
|
||||||
|
@ -44,7 +46,7 @@ namespace Oyster
|
||||||
|
|
||||||
bool stillSending;
|
bool stillSending;
|
||||||
bool closed;
|
bool closed;
|
||||||
|
std::string addr;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,12 @@ namespace Oyster
|
||||||
{
|
{
|
||||||
namespace Network
|
namespace Network
|
||||||
{
|
{
|
||||||
|
struct ConnectionInfo
|
||||||
|
{
|
||||||
|
int socket;
|
||||||
|
std::string addr;
|
||||||
|
};
|
||||||
|
|
||||||
class OysterByte;
|
class OysterByte;
|
||||||
class IConnection
|
class IConnection
|
||||||
{
|
{
|
||||||
|
@ -27,7 +33,7 @@ namespace Oyster
|
||||||
virtual int InitiateClient() { return false; };
|
virtual int InitiateClient() { return false; };
|
||||||
|
|
||||||
//Listen function to let client connect, only used by the server
|
//Listen function to let client connect, only used by the server
|
||||||
virtual int Listen() { return -1; };
|
virtual ConnectionInfo Listen() { return ConnectionInfo(); };
|
||||||
|
|
||||||
//enables the client to connect with a server with use of name and port
|
//enables the client to connect with a server with use of name and port
|
||||||
//(servers uses Listen instead of connect)
|
//(servers uses Listen instead of connect)
|
||||||
|
|
|
@ -1,27 +0,0 @@
|
||||||
#ifndef NETWORK_SERVER_ILISTENER_H
|
|
||||||
#define NETWORK_SERVER_ILISTENER_H
|
|
||||||
|
|
||||||
/////////////////////////////////////
|
|
||||||
// Created by Pontus Fransson 2013 //
|
|
||||||
/////////////////////////////////////
|
|
||||||
|
|
||||||
namespace Oyster
|
|
||||||
{
|
|
||||||
namespace Network
|
|
||||||
{
|
|
||||||
namespace Server
|
|
||||||
{
|
|
||||||
class IListener
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
virtual ~IListener() {}
|
|
||||||
virtual bool Init(unsigned int port) = 0;
|
|
||||||
virtual int Accept() = 0;
|
|
||||||
virtual void Shutdown() = 0;
|
|
||||||
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,8 +1,8 @@
|
||||||
#include "Listener.h"
|
#include "Listener.h"
|
||||||
|
|
||||||
using namespace Oyster::Network::Server;
|
|
||||||
using namespace Utility::DynamicMemory;
|
using namespace Utility::DynamicMemory;
|
||||||
using namespace Oyster::Thread;
|
using namespace Oyster::Thread;
|
||||||
|
using namespace Oyster::Network;
|
||||||
|
|
||||||
Listener::Listener()
|
Listener::Listener()
|
||||||
{
|
{
|
||||||
|
@ -11,7 +11,7 @@ Listener::Listener()
|
||||||
connection = NULL;
|
connection = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Listener::Listener(Oyster::Network::IPostBox<int>* postBox)
|
Listener::Listener(Oyster::Network::IPostBox<ConnectionInfo>* postBox)
|
||||||
{
|
{
|
||||||
this->isListening = false;
|
this->isListening = false;
|
||||||
connection = NULL;
|
connection = NULL;
|
||||||
|
@ -88,7 +88,7 @@ void Listener::Shutdown()
|
||||||
StopListen();
|
StopListen();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Listener::SetPostBox(Oyster::Network::IPostBox<int>* postBox)
|
void Listener::SetPostBox(Oyster::Network::IPostBox<ConnectionInfo>* postBox)
|
||||||
{
|
{
|
||||||
stdMutex.lock();
|
stdMutex.lock();
|
||||||
this->postBox = postBox;
|
this->postBox = postBox;
|
||||||
|
@ -97,21 +97,21 @@ void Listener::SetPostBox(Oyster::Network::IPostBox<int>* postBox)
|
||||||
|
|
||||||
int Listener::Accept()
|
int Listener::Accept()
|
||||||
{
|
{
|
||||||
int clientSocket = -1;
|
ConnectionInfo clientSocket = {0};
|
||||||
clientSocket = connection->Listen();
|
clientSocket = connection->Listen();
|
||||||
|
|
||||||
if(!this->isListening.load())
|
if(!this->isListening.load())
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if(clientSocket != -1)
|
if(clientSocket.socket != -1)
|
||||||
{
|
{
|
||||||
stdMutex.lock();
|
stdMutex.lock();
|
||||||
postBox->PostMessage(clientSocket);
|
postBox->PostMessage(clientSocket);
|
||||||
stdMutex.unlock();
|
stdMutex.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
return clientSocket;
|
return clientSocket.socket;
|
||||||
}
|
}
|
||||||
void Listener::StopListen()
|
void Listener::StopListen()
|
||||||
{
|
{
|
||||||
|
@ -120,7 +120,7 @@ void Listener::StopListen()
|
||||||
this->isListening = false;
|
this->isListening = false;
|
||||||
Connection c;
|
Connection c;
|
||||||
c.InitiateClient();
|
c.InitiateClient();
|
||||||
c.Connect(this->port, "127.0.0.1");
|
c.Connect(this->port, "127.0.0.1", false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bool Listener::DoWork()
|
bool Listener::DoWork()
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
// Created by Pontus Fransson 2013 //
|
// Created by Pontus Fransson 2013 //
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
|
|
||||||
#include "IListener.h"
|
|
||||||
#include "Connection.h"
|
#include "Connection.h"
|
||||||
#include "IPostBox.h"
|
#include "IPostBox.h"
|
||||||
#include "../../Misc/Thread/OysterThread.h"
|
#include "../../Misc/Thread/OysterThread.h"
|
||||||
|
@ -17,22 +16,20 @@ namespace Oyster
|
||||||
{
|
{
|
||||||
namespace Network
|
namespace Network
|
||||||
{
|
{
|
||||||
namespace Server
|
class Listener : public ::Oyster::Thread::IThreadObject
|
||||||
{
|
|
||||||
class Listener : public IListener, public ::Oyster::Thread::IThreadObject
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Listener();
|
Listener();
|
||||||
Listener(Oyster::Network::IPostBox<int>* postBox);
|
Listener(Oyster::Network::IPostBox<ConnectionInfo>* postBox);
|
||||||
~Listener();
|
~Listener();
|
||||||
|
|
||||||
bool Init(unsigned int port) override;
|
bool Init(unsigned int port);
|
||||||
bool Init(unsigned int port, bool start);
|
bool Init(unsigned int port, bool start);
|
||||||
bool Start();
|
bool Start();
|
||||||
void Stop();
|
void Stop();
|
||||||
void Shutdown();
|
void Shutdown();
|
||||||
|
|
||||||
void SetPostBox(IPostBox<int>* postBox);
|
void SetPostBox(IPostBox<ConnectionInfo>* postBox);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//Thread functions
|
//Thread functions
|
||||||
|
@ -51,11 +48,11 @@ namespace Oyster
|
||||||
OysterMutex mutex;
|
OysterMutex mutex;
|
||||||
std::mutex stdMutex;
|
std::mutex stdMutex;
|
||||||
|
|
||||||
IPostBox<int>* postBox;
|
IPostBox<ConnectionInfo>* postBox;
|
||||||
std::atomic<bool> isListening;
|
std::atomic<bool> isListening;
|
||||||
int port;
|
int port;
|
||||||
};
|
};
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -164,7 +164,6 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="Connection.h" />
|
<ClInclude Include="Connection.h" />
|
||||||
<ClInclude Include="IConnection.h" />
|
<ClInclude Include="IConnection.h" />
|
||||||
<ClInclude Include="IListener.h" />
|
|
||||||
<ClInclude Include="IPostBox.h" />
|
<ClInclude Include="IPostBox.h" />
|
||||||
<ClInclude Include="Listener.h" />
|
<ClInclude Include="Listener.h" />
|
||||||
<ClInclude Include="Messages\MessageHeader.h" />
|
<ClInclude Include="Messages\MessageHeader.h" />
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="Connection.h" />
|
<ClInclude Include="Connection.h" />
|
||||||
<ClInclude Include="IConnection.h" />
|
<ClInclude Include="IConnection.h" />
|
||||||
<ClInclude Include="IListener.h" />
|
|
||||||
<ClInclude Include="IPostBox.h" />
|
<ClInclude Include="IPostBox.h" />
|
||||||
<ClInclude Include="Listener.h" />
|
<ClInclude Include="Listener.h" />
|
||||||
<ClInclude Include="Messages\MessageHeader.h" />
|
<ClInclude Include="Messages\MessageHeader.h" />
|
||||||
|
|
|
@ -132,13 +132,14 @@ void Oyster::Graphics::Loading::UnloadDAN(void* data)
|
||||||
delete info;
|
delete info;
|
||||||
}
|
}
|
||||||
|
|
||||||
static wchar_t* charToWChar(const char* text)
|
static std::wstring charToWChar(const char* text)
|
||||||
{
|
{
|
||||||
// Convert to a wchar_t*
|
// Convert to a wchar_t*
|
||||||
size_t origsize = strlen(text) + 1;
|
size_t origsize = strlen(text) + 1;
|
||||||
size_t convertedChars = 0;
|
size_t convertedChars = 0;
|
||||||
wchar_t* wcstring = new wchar_t[origsize];
|
//wchar_t* wcstring = new wchar_t[origsize];
|
||||||
mbstowcs_s(&convertedChars, wcstring, origsize, text, _TRUNCATE);
|
std::wstring wcstring; wcstring.resize(origsize);
|
||||||
|
mbstowcs_s(&convertedChars, &wcstring[0], origsize, text, _TRUNCATE);
|
||||||
return wcstring;
|
return wcstring;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,7 +176,7 @@ void Oyster::Graphics::Loading::LoadDAN(const wchar_t filename[], Oyster::Resour
|
||||||
buffer = new char[4];
|
buffer = new char[4];
|
||||||
danFile.read(buffer, 4);
|
danFile.read(buffer, 4);
|
||||||
memcpy(&headerType, buffer, 4);
|
memcpy(&headerType, buffer, 4);
|
||||||
//delete[] buffer; // ( note: may crash here.)
|
delete[] buffer; // ( note: may crash here.)
|
||||||
|
|
||||||
// handle header type
|
// handle header type
|
||||||
switch ((HeaderType)headerType)
|
switch ((HeaderType)headerType)
|
||||||
|
@ -276,11 +277,14 @@ void Oyster::Graphics::Loading::LoadDAN(const wchar_t filename[], Oyster::Resour
|
||||||
delete[] buffer; // ( note: may crash here.)
|
delete[] buffer; // ( note: may crash here.)
|
||||||
|
|
||||||
//
|
//
|
||||||
ID3D11ShaderResourceView* diffuseMap = (ID3D11ShaderResourceView*)Oyster::Resource::OysterResource::LoadResource(charToWChar(materialHeader.diffuseMapPath), Oyster::Graphics::Loading::LoadTexture);
|
ID3D11ShaderResourceView* diffuseMap = (ID3D11ShaderResourceView*)Oyster::Resource::OysterResource::LoadResource(charToWChar(materialHeader.diffuseMapPath).c_str(), Oyster::Graphics::Loading::LoadTexture);
|
||||||
ID3D11ShaderResourceView* normalMap = (ID3D11ShaderResourceView*)Oyster::Resource::OysterResource::LoadResource(charToWChar(materialHeader.normalMapPath), Oyster::Graphics::Loading::LoadTexture);
|
ID3D11ShaderResourceView* normalMap = (ID3D11ShaderResourceView*)Oyster::Resource::OysterResource::LoadResource(charToWChar(materialHeader.normalMapPath).c_str(), Oyster::Graphics::Loading::LoadTexture);
|
||||||
modelInfo->Material.push_back(diffuseMap);
|
modelInfo->Material.push_back(diffuseMap);
|
||||||
modelInfo->Material.push_back(normalMap);
|
modelInfo->Material.push_back(normalMap);
|
||||||
|
|
||||||
|
delete materialHeader.normalMapPath;
|
||||||
|
delete materialHeader.diffuseMapPath;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// skeleton header
|
// skeleton header
|
||||||
|
@ -298,6 +302,7 @@ void Oyster::Graphics::Loading::LoadDAN(const wchar_t filename[], Oyster::Resour
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// close file
|
// close file
|
||||||
danFile.close();
|
danFile.close();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue