Broekn stuff to tobias
This commit is contained in:
parent
22a5db97f8
commit
91e825dbfb
|
@ -31,8 +31,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Game", "Game", "{20720CA7-7
|
|||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GameLogic", "Game\GameLogic\GameLogic.vcxproj", "{B1195BB9-B3A5-47F0-906C-8DEA384D1520}"
|
||||
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}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{52380DAA-0F4A-4D97-8E57-98DF39319CAF} = {52380DAA-0F4A-4D97-8E57-98DF39319CAF}
|
||||
|
@ -46,6 +44,10 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DanBiasServerLauncher", "Ga
|
|||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "aDanBiasGameLauncher", "Game\aDanBiasGameLauncher\aDanBiasGameLauncher.vcxproj", "{666FEA52-975F-41CD-B224-B19AF3C0ABBA}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ServerDependencies", "Game\ServerDependencies\ServerDependencies.vcxproj", "{52380DAA-0F4A-4D97-8E57-98DF39319CAF}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GameServer", "Game\GameServer\GameServer.vcxproj", "{143BD516-20A1-4890-A3E4-F8BFD02220E7}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Mixed Platforms = Debug|Mixed Platforms
|
||||
|
@ -212,18 +214,6 @@ Global
|
|||
{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.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.Build.0 = Debug|Win32
|
||||
{8690FDDF-C5B7-4C42-A337-BD5243F29B85}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
|
@ -284,6 +274,30 @@ Global
|
|||
{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.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
|
||||
{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
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -295,10 +309,11 @@ Global
|
|||
{460D625F-2AC9-4559-B809-0BA89CEAEDF4} = {C27B926E-B3EF-4990-8822-47580E43A0BE}
|
||||
{2A1BC987-AF42-4500-802D-89CD32FC1309} = {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}
|
||||
{DA2AA800-ED64-4649-8B3B-E7F1E3968B78} = {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}
|
||||
{52380DAA-0F4A-4D97-8E57-98DF39319CAF} = {20720CA7-795C-45AD-A302-9383A6DD503A}
|
||||
{143BD516-20A1-4890-A3E4-F8BFD02220E7} = {20720CA7-795C-45AD-A302-9383A6DD503A}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
<element>
|
||||
<id>UMLClass</id>
|
||||
<coordinates>
|
||||
<x>530</x>
|
||||
<y>320</y>
|
||||
<x>380</x>
|
||||
<y>360</y>
|
||||
<w>100</w>
|
||||
<h>30</h>
|
||||
</coordinates>
|
||||
|
@ -16,20 +16,8 @@
|
|||
<element>
|
||||
<id>UMLClass</id>
|
||||
<coordinates>
|
||||
<x>530</x>
|
||||
<y>250</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>
|
||||
<x>360</x>
|
||||
<y>540</y>
|
||||
<w>160</w>
|
||||
<h>80</h>
|
||||
</coordinates>
|
||||
|
@ -43,8 +31,8 @@
|
|||
<element>
|
||||
<id>UMLClass</id>
|
||||
<coordinates>
|
||||
<x>710</x>
|
||||
<y>320</y>
|
||||
<x>560</x>
|
||||
<y>360</y>
|
||||
<w>100</w>
|
||||
<h>30</h>
|
||||
</coordinates>
|
||||
|
@ -54,19 +42,8 @@
|
|||
<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>
|
||||
<x>400</x>
|
||||
<y>460</y>
|
||||
<w>50</w>
|
||||
<h>100</h>
|
||||
</coordinates>
|
||||
|
@ -76,8 +53,8 @@
|
|||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>600</x>
|
||||
<y>300</y>
|
||||
<x>450</x>
|
||||
<y>340</y>
|
||||
<w>130</w>
|
||||
<h>50</h>
|
||||
</coordinates>
|
||||
|
@ -87,19 +64,19 @@
|
|||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>600</x>
|
||||
<y>230</y>
|
||||
<w>180</w>
|
||||
<x>460</x>
|
||||
<y>270</y>
|
||||
<w>170</w>
|
||||
<h>110</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=>>>-</panel_attributes>
|
||||
<additional_attributes>160;90;160;30;30;30</additional_attributes>
|
||||
<additional_attributes>150;90;150;30;30;30</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>640</x>
|
||||
<y>410</y>
|
||||
<x>490</x>
|
||||
<y>450</y>
|
||||
<w>140</w>
|
||||
<h>140</h>
|
||||
</coordinates>
|
||||
|
@ -109,8 +86,8 @@
|
|||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>610</x>
|
||||
<y>140</y>
|
||||
<x>460</x>
|
||||
<y>180</y>
|
||||
<w>400</w>
|
||||
<h>150</h>
|
||||
</coordinates>
|
||||
|
@ -120,10 +97,10 @@
|
|||
<element>
|
||||
<id>UMLClass</id>
|
||||
<coordinates>
|
||||
<x>520</x>
|
||||
<y>160</y>
|
||||
<x>370</x>
|
||||
<y>200</y>
|
||||
<w>120</w>
|
||||
<h>30</h>
|
||||
<h>120</h>
|
||||
</coordinates>
|
||||
<panel_attributes>GameServer</panel_attributes>
|
||||
<additional_attributes/>
|
||||
|
@ -131,19 +108,19 @@
|
|||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>550</x>
|
||||
<y>160</y>
|
||||
<x>400</x>
|
||||
<y>290</y>
|
||||
<w>50</w>
|
||||
<h>110</h>
|
||||
<h>90</h>
|
||||
</coordinates>
|
||||
<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>
|
||||
<x>600</x>
|
||||
<y>300</y>
|
||||
<w>260</w>
|
||||
<h>80</h>
|
||||
</coordinates>
|
||||
|
@ -153,8 +130,8 @@
|
|||
<element>
|
||||
<type>com.umlet.element.Package</type>
|
||||
<coordinates>
|
||||
<x>990</x>
|
||||
<y>250</y>
|
||||
<x>840</x>
|
||||
<y>290</y>
|
||||
<w>120</w>
|
||||
<h>50</h>
|
||||
</coordinates>
|
||||
|
@ -165,8 +142,8 @@ bg=#a21aff</panel_attributes>
|
|||
<element>
|
||||
<id>UMLClass</id>
|
||||
<coordinates>
|
||||
<x>510</x>
|
||||
<y>20</y>
|
||||
<x>360</x>
|
||||
<y>120</y>
|
||||
<w>130</w>
|
||||
<h>40</h>
|
||||
</coordinates>
|
||||
|
@ -177,20 +154,20 @@ DanBiasServerAPI</panel_attributes>
|
|||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>550</x>
|
||||
<y>30</y>
|
||||
<x>400</x>
|
||||
<y>130</y>
|
||||
<w>50</w>
|
||||
<h>150</h>
|
||||
<h>90</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=>>>>-
|
||||
</panel_attributes>
|
||||
<additional_attributes>30;130;30;30</additional_attributes>
|
||||
<additional_attributes>30;70;30;30</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<id>UMLClass</id>
|
||||
<coordinates>
|
||||
<x>300</x>
|
||||
<y>320</y>
|
||||
<x>150</x>
|
||||
<y>360</y>
|
||||
<w>120</w>
|
||||
<h>30</h>
|
||||
</coordinates>
|
||||
|
@ -200,19 +177,19 @@ DanBiasServerAPI</panel_attributes>
|
|||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>330</x>
|
||||
<y>230</y>
|
||||
<w>220</w>
|
||||
<x>180</x>
|
||||
<y>270</y>
|
||||
<w>210</w>
|
||||
<h>110</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=->>>>></panel_attributes>
|
||||
<additional_attributes>200;30;30;30;30;90</additional_attributes>
|
||||
<additional_attributes>190;30;30;30;30;90</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>390</x>
|
||||
<y>300</y>
|
||||
<x>240</x>
|
||||
<y>340</y>
|
||||
<w>160</w>
|
||||
<h>50</h>
|
||||
</coordinates>
|
||||
|
@ -222,8 +199,8 @@ DanBiasServerAPI</panel_attributes>
|
|||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>330</x>
|
||||
<y>320</y>
|
||||
<x>180</x>
|
||||
<y>360</y>
|
||||
<w>200</w>
|
||||
<h>210</h>
|
||||
</coordinates>
|
||||
|
@ -233,8 +210,8 @@ DanBiasServerAPI</panel_attributes>
|
|||
<element>
|
||||
<type>com.umlet.element.Package</type>
|
||||
<coordinates>
|
||||
<x>990</x>
|
||||
<y>370</y>
|
||||
<x>840</x>
|
||||
<y>410</y>
|
||||
<w>120</w>
|
||||
<h>50</h>
|
||||
</coordinates>
|
||||
|
@ -245,8 +222,8 @@ bg=blue</panel_attributes>
|
|||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>750</x>
|
||||
<y>320</y>
|
||||
<x>600</x>
|
||||
<y>360</y>
|
||||
<w>260</w>
|
||||
<h>90</h>
|
||||
</coordinates>
|
||||
|
@ -256,8 +233,8 @@ bg=blue</panel_attributes>
|
|||
<element>
|
||||
<type>com.umlet.element.Package</type>
|
||||
<coordinates>
|
||||
<x>990</x>
|
||||
<y>310</y>
|
||||
<x>840</x>
|
||||
<y>350</y>
|
||||
<w>120</w>
|
||||
<h>40</h>
|
||||
</coordinates>
|
||||
|
@ -270,8 +247,8 @@ bg=blue
|
|||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>780</x>
|
||||
<y>300</y>
|
||||
<x>630</x>
|
||||
<y>340</y>
|
||||
<w>230</w>
|
||||
<h>50</h>
|
||||
</coordinates>
|
||||
|
@ -281,8 +258,8 @@ bg=blue
|
|||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>640</x>
|
||||
<y>380</y>
|
||||
<x>490</x>
|
||||
<y>420</y>
|
||||
<w>370</w>
|
||||
<h>190</h>
|
||||
</coordinates>
|
||||
|
@ -292,8 +269,8 @@ bg=blue
|
|||
<element>
|
||||
<id>UMLClass</id>
|
||||
<coordinates>
|
||||
<x>320</x>
|
||||
<y>120</y>
|
||||
<x>170</x>
|
||||
<y>160</y>
|
||||
<w>130</w>
|
||||
<h>90</h>
|
||||
</coordinates>
|
||||
|
@ -308,8 +285,8 @@ elementstyle=wordwrap
|
|||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>420</x>
|
||||
<y>140</y>
|
||||
<x>270</x>
|
||||
<y>180</y>
|
||||
<w>120</w>
|
||||
<h>50</h>
|
||||
</coordinates>
|
||||
|
@ -320,8 +297,8 @@ elementstyle=wordwrap
|
|||
<element>
|
||||
<id>UMLClass</id>
|
||||
<coordinates>
|
||||
<x>510</x>
|
||||
<y>400</y>
|
||||
<x>360</x>
|
||||
<y>440</y>
|
||||
<w>160</w>
|
||||
<h>50</h>
|
||||
</coordinates>
|
||||
|
@ -333,8 +310,8 @@ elementstyle=wordwrap
|
|||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>550</x>
|
||||
<y>320</y>
|
||||
<x>400</x>
|
||||
<y>360</y>
|
||||
<w>50</w>
|
||||
<h>100</h>
|
||||
</coordinates>
|
||||
|
@ -344,8 +321,8 @@ elementstyle=wordwrap
|
|||
<element>
|
||||
<type>com.umlet.element.Package</type>
|
||||
<coordinates>
|
||||
<x>990</x>
|
||||
<y>430</y>
|
||||
<x>840</x>
|
||||
<y>470</y>
|
||||
<w>120</w>
|
||||
<h>40</h>
|
||||
</coordinates>
|
||||
|
@ -356,8 +333,8 @@ bg=#aaaaa</panel_attributes>
|
|||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>310</x>
|
||||
<y>320</y>
|
||||
<x>160</x>
|
||||
<y>360</y>
|
||||
<w>770</w>
|
||||
<h>300</h>
|
||||
</coordinates>
|
||||
|
@ -367,8 +344,8 @@ bg=#aaaaa</panel_attributes>
|
|||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>1080</x>
|
||||
<y>260</y>
|
||||
<x>930</x>
|
||||
<y>300</y>
|
||||
<w>70</w>
|
||||
<h>210</h>
|
||||
</coordinates>
|
||||
|
@ -378,8 +355,8 @@ bg=#aaaaa</panel_attributes>
|
|||
<element>
|
||||
<id>UMLClass</id>
|
||||
<coordinates>
|
||||
<x>160</x>
|
||||
<y>310</y>
|
||||
<x>10</x>
|
||||
<y>350</y>
|
||||
<w>120</w>
|
||||
<h>40</h>
|
||||
</coordinates>
|
||||
|
@ -390,8 +367,8 @@ INetworkSession</panel_attributes>
|
|||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>250</x>
|
||||
<y>300</y>
|
||||
<x>100</x>
|
||||
<y>340</y>
|
||||
<w>70</w>
|
||||
<h>50</h>
|
||||
</coordinates>
|
||||
|
@ -401,8 +378,8 @@ INetworkSession</panel_attributes>
|
|||
<element>
|
||||
<id>UMLClass</id>
|
||||
<coordinates>
|
||||
<x>710</x>
|
||||
<y>410</y>
|
||||
<x>560</x>
|
||||
<y>450</y>
|
||||
<w>100</w>
|
||||
<h>30</h>
|
||||
</coordinates>
|
||||
|
@ -412,8 +389,8 @@ INetworkSession</panel_attributes>
|
|||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>730</x>
|
||||
<y>320</y>
|
||||
<x>580</x>
|
||||
<y>360</y>
|
||||
<w>50</w>
|
||||
<h>110</h>
|
||||
</coordinates>
|
||||
|
@ -423,8 +400,8 @@ INetworkSession</panel_attributes>
|
|||
<element>
|
||||
<id>UMLClass</id>
|
||||
<coordinates>
|
||||
<x>150</x>
|
||||
<y>420</y>
|
||||
<x>0</x>
|
||||
<y>460</y>
|
||||
<w>160</w>
|
||||
<h>50</h>
|
||||
</coordinates>
|
||||
|
|
|
@ -290,7 +290,7 @@ void GameState::Protocol( ObjPos* pos )
|
|||
|
||||
for (unsigned int i = 0; i < privData->object.size(); i++)
|
||||
{
|
||||
if(privData->object[i]->GetId() == pos->object_ID)
|
||||
if(privData->object[i] && privData->object[i]->GetId() == pos->object_ID)
|
||||
{
|
||||
privData->object[i]->setPos(world);
|
||||
|
||||
|
|
|
@ -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,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,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>
|
||||
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||
<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;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>$(OutDir)..\DLL\;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
|
@ -79,7 +79,7 @@
|
|||
<OutDir>$(SolutionDir)..\Bin\Executable\</OutDir>
|
||||
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||
<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;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>$(OutDir)..\DLL\;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
|
@ -87,7 +87,7 @@
|
|||
<OutDir>$(SolutionDir)..\Bin\Executable\</OutDir>
|
||||
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||
<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;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>$(OutDir)..\DLL\;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
|
@ -95,7 +95,7 @@
|
|||
<OutDir>$(SolutionDir)..\Bin\Executable\</OutDir>
|
||||
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||
<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;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>$(OutDir)..\DLL\;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include <vld.h>
|
||||
|
||||
|
||||
#include <DanBiasServerAPI.h>
|
||||
#include <GameServerAPI.h>
|
||||
|
||||
int WINAPI WinMain( HINSTANCE hinst, HINSTANCE prevInst, PSTR cmdLine, int cmdShow)
|
||||
{
|
||||
|
@ -15,10 +15,14 @@ int WINAPI WinMain( HINSTANCE hinst, HINSTANCE prevInst, PSTR cmdLine, int cmdSh
|
|||
{
|
||||
return cmdShow;
|
||||
}
|
||||
if( DanBias::DanBiasServerAPI::Initiate() == DanBias::DanBiasServerReturn_Sucess)
|
||||
|
||||
DanBias::GameServerAPI::GameInitDesc desc;
|
||||
desc.connectionPort = 15151;
|
||||
desc.maxNumberOfClients = 0;
|
||||
desc.threaded = false;
|
||||
if( !DanBias::GameServerAPI::Create(desc) == DanBias::DanBiasServerReturn_Sucess)
|
||||
{
|
||||
DanBias::DanBiasServerAPI::Run();
|
||||
DanBias::DanBiasServerAPI::Release();
|
||||
|
||||
}
|
||||
return cmdShow;
|
||||
}
|
|
@ -45,14 +45,18 @@ namespace GameLogic
|
|||
|
||||
struct Protocol_LobbyStartGame :public Oyster::Network::CustomProtocolObject
|
||||
{
|
||||
char gameId;
|
||||
short gameId;
|
||||
|
||||
Protocol_LobbyStartGame()
|
||||
{
|
||||
this->protocol[protocol_INDEX_ID].value = protocol_Lobby_Start;
|
||||
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
|
||||
{
|
||||
|
@ -73,6 +77,10 @@ namespace GameLogic
|
|||
this->protocol[protocol_INDEX_ID].type = Oyster::Network::NetAttributeType_Short;
|
||||
|
||||
this->protocol[1].type = Oyster::Network::NetAttributeType_Short;
|
||||
}
|
||||
Protocol_LobbyLogin(Oyster::Network::CustomNetProtocol& p)
|
||||
{
|
||||
|
||||
}
|
||||
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].type = Oyster::Network::NetAttributeType_Short;
|
||||
}
|
||||
Protocol_LobbyRefresh(Oyster::Network::CustomNetProtocol& o)
|
||||
{
|
||||
|
||||
}
|
||||
Oyster::Network::CustomNetProtocol* GetProtocol() override
|
||||
{ return &protocol; }
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
/////////////////////////////////////////////////////////////////////
|
||||
// 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>
|
||||
|
||||
namespace DanBias
|
||||
{
|
||||
class GameClient
|
||||
{
|
||||
public:
|
||||
GameClient(Oyster::Network::NetworkClient client, GameLogic::IPlayerData* player);
|
||||
virtual~GameClient();
|
||||
|
||||
//void SetCallback(Oyster::Callback::OysterCallback<void, NetworkSession::NetEvent> value);
|
||||
|
||||
GameLogic::IPlayerData* GetPlayer();
|
||||
GameLogic::IPlayerData* ReleasePlayer();
|
||||
Oyster::Network::NetworkClient* GetClient();
|
||||
Oyster::Network::NetworkClient ReleaseClient();
|
||||
int GetID() const;
|
||||
|
||||
private:
|
||||
GameLogic::IPlayerData* player;
|
||||
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>
|
||||
|
||||
namespace DanBias
|
||||
{
|
||||
class GameLobby :public Oyster::Network::NetworkSession
|
||||
{
|
||||
public:
|
||||
GameLobby();
|
||||
virtual~GameLobby();
|
||||
|
||||
void Release();
|
||||
|
||||
void Frame();
|
||||
|
||||
//void ClientEventCallback(NetEvent<Client*, Client::ClientEventArgs> e) override;
|
||||
|
||||
private:
|
||||
void ParseEvents();
|
||||
void ParseGeneralProtocol(Oyster::Network::CustomNetProtocol& p, Oyster::Network::NetworkClient* c);
|
||||
void ParseLobbyProtocol(Oyster::Network::CustomNetProtocol& p, Oyster::Network::NetworkClient* c);
|
||||
|
||||
//Lobby events
|
||||
void LobbyStartGame(GameLogic::Protocol_LobbyStartGame& p, Oyster::Network::NetworkClient* c);
|
||||
void LobbyRefresh(GameLogic::Protocol_LobbyRefresh& p, Oyster::Network::NetworkClient* c);
|
||||
|
||||
//General events
|
||||
void GeneralStatus(GameLogic::Protocol_General_Status& p, Oyster::Network::NetworkClient* c);
|
||||
void GeneralText(GameLogic::Protocol_General_Text& p, Oyster::Network::NetworkClient* c);
|
||||
|
||||
private:
|
||||
void ClientEventCallback(Oyster::Network::NetEvent<Oyster::Network::NetworkClient*, Oyster::Network::NetworkClient::ClientEventArgs> e) override;
|
||||
void ClientConnectedEvent(Oyster::Network::NetEvent<Oyster::Network::NetworkClient*, Oyster::Network::NetworkClient::ClientEventArgs> e) override;
|
||||
|
||||
private:
|
||||
Utility::WinTimer timer;
|
||||
float refreshFrequency;
|
||||
};
|
||||
}//End namespace DanBias
|
||||
#endif // !DANBIASGAME_GAMELOBBY_H
|
|
@ -0,0 +1,33 @@
|
|||
/////////////////////////////////////////////////////////////////////
|
||||
// Created by [Dennis Andersen] [2013]
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
#ifndef DANBIASSERVER_GAME_SERVER_H
|
||||
#define DANBIASSERVER_GAME_SERVER_H
|
||||
|
||||
#include "GameServerAPI.h"
|
||||
#include "GameLobby.h"
|
||||
#include <NetworkServer.h>
|
||||
#include <Utilities.h>
|
||||
|
||||
namespace DanBias
|
||||
{
|
||||
class GameServer
|
||||
{
|
||||
public:
|
||||
GameServer();
|
||||
virtual~GameServer();
|
||||
|
||||
DanBiasServerReturn Create(const GameServerAPI::GameInitDesc& desc);
|
||||
|
||||
private:
|
||||
static void Run(GameServer* owner);
|
||||
void Run();
|
||||
void Release();
|
||||
|
||||
private:
|
||||
int maxClients;
|
||||
Utility::DynamicMemory::SmartPointer<GameLobby> lobby;
|
||||
Utility::DynamicMemory::SmartPointer<Oyster::Network::NetworkServer> server;
|
||||
};
|
||||
}// End namspace DanBias
|
||||
#endif // !DANBIASSERVER_DBSERVER_H
|
|
@ -19,9 +19,10 @@
|
|||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{52380DAA-0F4A-4D97-8E57-98DF39319CAF}</ProjectGuid>
|
||||
<ProjectGuid>{143BD516-20A1-4890-A3E4-F8BFD02220E7}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>DanBiasServer</RootNamespace>
|
||||
<RootNamespace>GameServer</RootNamespace>
|
||||
<ProjectName>GameServer</ProjectName>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
|
@ -73,32 +74,32 @@
|
|||
<OutDir>$(SolutionDir)..\Bin\DLL\</OutDir>
|
||||
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||
<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>
|
||||
<LibraryPath>$(OutDir);$(SolutionDir)..\External\Lib\WindowManager\;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath)</LibraryPath>
|
||||
<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;$(SolutionDir)..\External\Lib\ServerDependencies\;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)..\Bin\DLL\</OutDir>
|
||||
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||
<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>
|
||||
<LibraryPath>$(OutDir);$(SolutionDir)..\External\Lib\WindowManager\;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath)</LibraryPath>
|
||||
<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;$(SolutionDir)..\External\Lib\ServerDependencies\;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)..\Bin\DLL\</OutDir>
|
||||
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||
<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>
|
||||
<LibraryPath>$(OutDir);$(SolutionDir)..\External\Lib\WindowManager\;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath)</LibraryPath>
|
||||
<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;$(SolutionDir)..\External\Lib\ServerDependencies\;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)..\Bin\DLL\</OutDir>
|
||||
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||
<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>
|
||||
<LibraryPath>$(OutDir);$(SolutionDir)..\External\Lib\WindowManager\;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath)</LibraryPath>
|
||||
<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;$(SolutionDir)..\External\Lib\ServerDependencies\;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
|
@ -173,39 +174,35 @@
|
|||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="AdminInterface\AdminInterface.cpp" />
|
||||
<ClCompile Include="GameSession\GameSessionManager.cpp" />
|
||||
<ClCompile Include="DanBiasServerAPI.cpp" />
|
||||
<ClCompile Include="DLLMain.cpp" />
|
||||
<ClCompile Include="GameServer.cpp" />
|
||||
<ClCompile Include="GameSession\GameClient.cpp" />
|
||||
<ClCompile Include="GameSession\GameSession_Events.cpp" />
|
||||
<ClCompile Include="GameSession\GameSession_General.cpp" />
|
||||
<ClCompile Include="GameSession\GameSession_Network.cpp" />
|
||||
<ClCompile Include="LobbySessions\INetworkSession.cpp" />
|
||||
<ClCompile Include="LobbySessions\LobbyClient.cpp" />
|
||||
<ClCompile Include="LobbySessions\GameLobby.cpp" />
|
||||
<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" />
|
||||
<ClCompile Include="Implementation\DLLMain.cpp" />
|
||||
<ClCompile Include="Implementation\GameClient.cpp" />
|
||||
<ClCompile Include="Implementation\GameLobby.cpp" />
|
||||
<ClCompile Include="Implementation\GameServer.cpp" />
|
||||
<ClCompile Include="Implementation\GameSessionManager.cpp" />
|
||||
<ClCompile Include="Implementation\GameSession_Events.cpp" />
|
||||
<ClCompile Include="Implementation\GameSession_General.cpp" />
|
||||
<ClCompile Include="Implementation\GameSession_Logic.cpp" />
|
||||
<ClCompile Include="Implementation\GameSession_Network.cpp" />
|
||||
<ClCompile Include="Implementation\LobbyGeneralProtocolParser.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Implementation\LobbyProtocolParser.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="AdminInterface\AdminInterface.h" />
|
||||
<ClInclude Include="Event\EventManager.h" />
|
||||
<ClInclude Include="GameClient.h" />
|
||||
<ClInclude Include="GameLobby.h" />
|
||||
<ClInclude Include="GameServer.h" />
|
||||
<ClInclude Include="GameSession\GameSessionManager.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" />
|
||||
<ClInclude Include="GameServerAPI.h" />
|
||||
<ClInclude Include="GameSession.h" />
|
||||
<ClInclude Include="GameSessionManager.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Misc\Misc.vcxproj">
|
|
@ -24,12 +24,18 @@ namespace DanBias
|
|||
|
||||
extern "C"
|
||||
{
|
||||
class DANBIAS_SERVER_DLL DanBiasServerAPI
|
||||
class DANBIAS_SERVER_DLL GameServerAPI
|
||||
{
|
||||
public:
|
||||
static DanBiasServerReturn Initiate();
|
||||
static DanBiasServerReturn Run();
|
||||
static DanBiasServerReturn Release();
|
||||
struct GameInitDesc
|
||||
{
|
||||
//stuff
|
||||
int connectionPort;
|
||||
int maxNumberOfClients;
|
||||
bool threaded;
|
||||
};
|
||||
public:
|
||||
static DanBiasServerReturn Create(const GameInitDesc& desc);
|
||||
};//End class DanBiasServer
|
||||
}//End Extern "C"
|
||||
} //End namspace DanBias
|
|
@ -7,18 +7,18 @@
|
|||
//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 "..\LobbySessions\NetworkSession.h"
|
||||
|
||||
#include "GameClient.h"
|
||||
#include <WinTimer.h>
|
||||
#include <PostBox\IPostBox.h>
|
||||
#include <Thread\OysterThread.h>
|
||||
#include <GameAPI.h>
|
||||
#include <Queue.h>
|
||||
#include <NetworkSession.h>
|
||||
|
||||
namespace DanBias
|
||||
{
|
||||
class LobbyClient;
|
||||
class GameClient;
|
||||
class GameSession : public Oyster::Thread::IThreadObject, public INetworkSession
|
||||
class GameSession : public Oyster::Thread::IThreadObject
|
||||
{
|
||||
public:
|
||||
/**
|
||||
|
@ -28,7 +28,7 @@ namespace DanBias
|
|||
{
|
||||
std::wstring mapName;
|
||||
NetworkSession* owner;
|
||||
Utility::DynamicMemory::DynamicArray<Utility::DynamicMemory::SmartPointer<LobbyClient>> clients;
|
||||
Utility::DynamicMemory::DynamicArray<NetworkClient> clients;
|
||||
};
|
||||
|
||||
public:
|
||||
|
@ -44,7 +44,7 @@ namespace DanBias
|
|||
/** Join an existing/running game session
|
||||
* @param client The client to attach to the session
|
||||
*/
|
||||
bool Join(Utility::DynamicMemory::SmartPointer<LobbyClient> client);
|
||||
bool Join(Utility::DynamicMemory::SmartPointer<NetworkSession> client);
|
||||
|
||||
/**
|
||||
* Closes the game session
|
||||
|
@ -82,7 +82,7 @@ namespace DanBias
|
|||
private:
|
||||
|
||||
Utility::DynamicMemory::DynamicArray<Utility::DynamicMemory::SmartPointer<GameClient>> clients;
|
||||
Oyster::IPostBox<DanBias::NetworkSession::NetEvent> *box;
|
||||
//Oyster::PostBox<DanBias::NetworkSession::NetEvent> *box;
|
||||
Oyster::Thread::OysterThread worker;
|
||||
GameLogic::GameAPI& gameInstance;
|
||||
GameLogic::ILevelData *levelData;
|
||||
|
@ -93,8 +93,6 @@ namespace DanBias
|
|||
|
||||
static void ObjectMove(GameLogic::IObjectData* movedObject);
|
||||
|
||||
private:
|
||||
friend class AdminInterface;
|
||||
|
||||
};//End GameSession
|
||||
}//End namespace DanBias
|
|
@ -4,19 +4,19 @@
|
|||
#ifndef DANBIASSERVER_GAME_SEESION_MANAGER_H
|
||||
#define DANBIASSERVER_GAME_SEESION_MANAGER_H
|
||||
|
||||
#include <NetworkSession.h>
|
||||
#include <string>
|
||||
#include <Utilities.h>
|
||||
#include <DynamicArray.h>
|
||||
|
||||
using namespace Oyster::Network;
|
||||
|
||||
namespace DanBias
|
||||
{
|
||||
class LobbyClient;
|
||||
class NetworkSession;
|
||||
|
||||
struct GameSessionDescription
|
||||
{
|
||||
std::wstring mapName;
|
||||
Utility::DynamicMemory::DynamicArray<Utility::DynamicMemory::SmartPointer<LobbyClient>> clients;
|
||||
Utility::DynamicMemory::DynamicArray<NetworkClient> clients;
|
||||
NetworkSession* exitDestionation; //The new owner when session dies
|
||||
};
|
||||
struct GameSessionInfo
|
||||
|
@ -49,7 +49,7 @@ namespace DanBias
|
|||
* @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);
|
||||
static bool JoinSession(int session, Utility::DynamicMemory::SmartPointer<NetworkSession> client);
|
||||
|
||||
/**
|
||||
* Gets information about a given session
|
||||
|
@ -67,7 +67,7 @@ namespace DanBias
|
|||
/**
|
||||
* Close all sessions.
|
||||
*/
|
||||
static void CloseSession();
|
||||
static void CloseSessions();
|
||||
|
||||
/**
|
||||
* Get total sessions running
|
|
@ -0,0 +1,50 @@
|
|||
/////////////////////////////////////////////////////////////////////
|
||||
// Created by [Dennis Andersen] [2013]
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "..\GameClient.h"
|
||||
#include <NetworkSession.h>
|
||||
#include <Protocols.h>
|
||||
|
||||
using namespace Utility::DynamicMemory;
|
||||
using namespace DanBias;
|
||||
using namespace GameLogic;
|
||||
|
||||
static int gameClientIDCount = 1;
|
||||
|
||||
GameClient::GameClient(Oyster::Network::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;
|
||||
}
|
||||
Oyster::Network::NetworkClient* GameClient::GetClient()
|
||||
{
|
||||
return &this->client;
|
||||
}
|
||||
Oyster::Network::NetworkClient GameClient::ReleaseClient()
|
||||
{
|
||||
Oyster::Network::NetworkClient temp = this->client;
|
||||
return temp;
|
||||
}
|
||||
int GameClient::GetID() const
|
||||
{
|
||||
return this->id;
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
/////////////////////////////////////////////////////////////////////
|
||||
// Created by [Dennis Andersen] [2013]
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
#include "..\GameLobby.h"
|
||||
#include <PlayerProtocols.h>
|
||||
#include <PostBox\PostBox.h>
|
||||
|
||||
using namespace Utility::DynamicMemory;
|
||||
using namespace Oyster::Network;
|
||||
using namespace Oyster;
|
||||
|
||||
namespace DanBias
|
||||
{
|
||||
GameLobby::GameLobby()
|
||||
{ }
|
||||
|
||||
GameLobby::~GameLobby()
|
||||
{ }
|
||||
|
||||
void GameLobby::Release()
|
||||
{ }
|
||||
|
||||
void GameLobby::Frame()
|
||||
{
|
||||
ParseEvents();
|
||||
}
|
||||
|
||||
void GameLobby::ClientEventCallback(NetEvent<NetworkClient*, NetworkClient::ClientEventArgs> e)
|
||||
{
|
||||
|
||||
}
|
||||
void GameLobby::ClientConnectedEvent(NetEvent<NetworkClient*, NetworkClient::ClientEventArgs> e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//////// Private
|
||||
void GameLobby::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
|
|
@ -0,0 +1,139 @@
|
|||
/////////////////////////////////////////////////////////////////////
|
||||
// Created by [Dennis Andersen] [2013]
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
#define NOMINMAX
|
||||
#include <Windows.h>
|
||||
#include <WindowShell.h>
|
||||
#include <iostream>
|
||||
|
||||
|
||||
#include "..\GameServer.h"
|
||||
#include "..\GameSessionManager.h"
|
||||
#include "..\GameSession.h"
|
||||
|
||||
#include <Thread\OysterThread.h>
|
||||
#include <Utilities.h>
|
||||
#include <NetworkClient.h>
|
||||
#include <thread>
|
||||
#include <CollisionManager.h>
|
||||
|
||||
namespace DanBias
|
||||
{
|
||||
using namespace Oyster::Network;
|
||||
|
||||
GameServer* instance = 0;
|
||||
std::thread workerThread;
|
||||
typedef void(*WorkerThreadFnc)(GameServer*);
|
||||
|
||||
DanBiasServerReturn GameServerAPI::Create(const GameInitDesc& desc)
|
||||
{
|
||||
if(!instance)
|
||||
instance = new GameServer();
|
||||
|
||||
return instance->Create(desc);
|
||||
}
|
||||
|
||||
|
||||
|
||||
GameServer::GameServer()
|
||||
: maxClients(0)
|
||||
{ }
|
||||
GameServer::~GameServer()
|
||||
{ }
|
||||
DanBiasServerReturn GameServer::Create(const GameServerAPI::GameInitDesc& desc)
|
||||
{
|
||||
this->maxClients = desc.maxNumberOfClients;
|
||||
this->server = new NetworkServer();
|
||||
this->lobby = new GameLobby();
|
||||
|
||||
if(desc.threaded)
|
||||
{
|
||||
if(!this->server->Init(desc.connectionPort, this->lobby))
|
||||
return DanBiasServerReturn_Error;
|
||||
|
||||
if(!this->server->Start())
|
||||
return DanBiasServerReturn_Error;
|
||||
|
||||
WorkerThreadFnc temp = GameServer::Run;
|
||||
workerThread = std::thread(temp, this);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!this->server->Init(desc.connectionPort, this->lobby))
|
||||
return DanBiasServerReturn_Error;
|
||||
|
||||
if(!this->server->Start())
|
||||
return DanBiasServerReturn_Error;
|
||||
|
||||
Run();
|
||||
}
|
||||
|
||||
return DanBiasServerReturn_Sucess;
|
||||
}
|
||||
void GameServer::Run(GameServer* owner)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
owner->server->ProcessConnectedClients();
|
||||
owner->lobby->ProcessClients();
|
||||
|
||||
if(GetAsyncKeyState(0x51)) //Q for exit
|
||||
break;
|
||||
}
|
||||
}
|
||||
void GameServer::Run()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
this->server->ProcessConnectedClients();
|
||||
this->lobby->Frame();
|
||||
|
||||
if(GetAsyncKeyState(0x51)) //Q for exit
|
||||
break;
|
||||
}
|
||||
}
|
||||
void GameServer::Release()
|
||||
{
|
||||
GameSessionManager::CloseSessions();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//void GameServer::ClientConnected(NetworkClient* client)
|
||||
//{
|
||||
// static bool myTest = false;
|
||||
// static int sessionId = -1;
|
||||
// printf("Client with ID [%i] connected.\n", client->GetID());
|
||||
//
|
||||
// if(!myTest)
|
||||
// {
|
||||
// Utility::DynamicMemory::SmartPointer<NetworkSession> c = new Client(client);
|
||||
//
|
||||
// GameSessionDescription desc;
|
||||
// desc.mapName = L"test";
|
||||
// desc.clients.Push(c);
|
||||
// desc.exitDestionation = this->lobby;
|
||||
// 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<NetworkSession> c = new NetworkSession(client);
|
||||
// GameSessionManager::JoinSession(sessionId, c);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// //Utility::DynamicMemory::SmartPointer<NetworkSession> c = new NetworkSession(client);
|
||||
// //this->mainLobby->Attach(c, this->mainLobby->GetPostbox());
|
||||
//}
|
||||
}//End namespace DanBias
|
|
@ -1,10 +1,8 @@
|
|||
/////////////////////////////////////////////////////////////////////
|
||||
// Created by [Dennis Andersen] [2013]
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
#include "GameSessionManager.h"
|
||||
|
||||
#include "..\LobbySessions\LobbyClient.h"
|
||||
#include "GameSession.h"
|
||||
#include "..\GameSessionManager.h"
|
||||
#include "..\GameSession.h"
|
||||
#include <DynamicArray.h>
|
||||
|
||||
using namespace DanBias;
|
||||
|
@ -75,7 +73,7 @@ bool GameSessionManager::StartSession(int session)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool GameSessionManager::JoinSession(int session, Utility::DynamicMemory::SmartPointer<LobbyClient> client)
|
||||
bool GameSessionManager::JoinSession(int session, Utility::DynamicMemory::SmartPointer<NetworkSession> client)
|
||||
{
|
||||
int i = -1;
|
||||
if((i = gameSessionData.Existst(session)) == -1) return false;
|
||||
|
@ -97,7 +95,7 @@ void GameSessionManager::GetSessionInfo(int session, GameSessionInfo& data)
|
|||
//data.numberOfPlayers = gameSessionData.sessions[i]->
|
||||
}
|
||||
|
||||
void GameSessionManager::CloseSession()
|
||||
void GameSessionManager::CloseSessions()
|
||||
{
|
||||
for (unsigned int i = 0; i < gameSessionData.sessions.Size(); i++)
|
||||
{
|
|
@ -1,9 +1,10 @@
|
|||
/////////////////////////////////////////////////////////////////////
|
||||
// Created by [Dennis Andersen] [2013]
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
#include "GameSession.h"
|
||||
#include "GameClient.h"
|
||||
#include "..\GameSession.h"
|
||||
#include "..\GameClient.h"
|
||||
|
||||
#include <NetworkServerEventStruct.h>
|
||||
#include <Protocols.h>
|
||||
#include <PostBox\PostBox.h>
|
||||
#include <GameLogicStates.h>
|
|
@ -1,8 +1,8 @@
|
|||
/////////////////////////////////////////////////////////////////////
|
||||
// Created by [Dennis Andersen] [2013]
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
#include "GameSession.h"
|
||||
#include "GameClient.h"
|
||||
#include "..\GameSession.h"
|
||||
#include "..\GameClient.h"
|
||||
#include "..\GameServer.h"
|
||||
#include <Protocols.h>
|
||||
#include <PostBox\PostBox.h>
|
||||
|
@ -105,7 +105,7 @@ namespace DanBias
|
|||
}
|
||||
}
|
||||
|
||||
bool GameSession::Join(Utility::DynamicMemory::SmartPointer<LobbyClient> client)
|
||||
bool GameSession::Join(Utility::DynamicMemory::SmartPointer<NetworkSession> client)
|
||||
{
|
||||
if(!this->isCreated) return false;
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
/////////////////////////////////////////////////////////////////////
|
||||
// Created by [Dennis Andersen] [2013]
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
#include "GameSession.h"
|
||||
#include "GameClient.h"
|
||||
#include "..\GameSession.h"
|
||||
#include "..\GameClient.h"
|
||||
|
||||
#include <Protocols.h>
|
||||
#include <PostBox\PostBox.h>
|
|
@ -1,8 +1,8 @@
|
|||
/////////////////////////////////////////////////////////////////////
|
||||
// Created by [Dennis Andersen] [2013]
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
#include "GameSession.h"
|
||||
#include "GameClient.h"
|
||||
#include "..\GameSession.h"
|
||||
#include "..\GameClient.h"
|
||||
|
||||
#include <Protocols.h>
|
||||
#include <PostBox\PostBox.h>
|
|
@ -0,0 +1,52 @@
|
|||
#include "GameLobby.h"
|
||||
#include "NetworkSession.h"
|
||||
|
||||
using namespace DanBias;
|
||||
using namespace GameLogic;
|
||||
|
||||
void GameLobby::ParseGeneralProtocol(Oyster::Network::CustomNetProtocol& p, DanBias::NetworkSession* c)
|
||||
{
|
||||
switch (p[0].value.netShort)
|
||||
{
|
||||
case protocol_General_Status:
|
||||
{
|
||||
GeneralStatus(GameLogic::Protocol_General_Status(p), c);
|
||||
} break;
|
||||
case protocol_General_Text:
|
||||
{
|
||||
GeneralText(GameLogic::Protocol_General_Text(p), c);
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////
|
||||
|
||||
void GameLobby::GeneralStatus(GameLogic::Protocol_General_Status& p, DanBias::NetworkSession* 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, DanBias::NetworkSession* c)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
#include "..\GameLobby.h"
|
||||
|
||||
using namespace DanBias;
|
||||
|
||||
void GameLobby::ParseLobbyProtocol(Oyster::Network::CustomNetProtocol& p, DanBias::NetworkSession* c)
|
||||
{
|
||||
switch (p[0].value.netShort)
|
||||
{
|
||||
case protocol_Lobby_Start:
|
||||
LobbyStartGame(GameLogic::Protocol_LobbyStartGame(p), c);
|
||||
break;
|
||||
|
||||
case protocol_Lobby_Refresh:
|
||||
LobbyRefresh(GameLogic::Protocol_LobbyRefresh(p), c);
|
||||
break;
|
||||
case protocol_Lobby_Login:
|
||||
{
|
||||
LobbyLogin(GameLogic::Protocol_LobbyLogin(p), c);
|
||||
} break;
|
||||
case protocol_Lobby_Join:
|
||||
{
|
||||
LobbyJoin(GameLogic::Protocol_LobbyJoin(p), c);
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
void GameLobby::LobbyStartGame(GameLogic::Protocol_LobbyStartGame& p, DanBias::NetworkSession* c)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void GameLobby::LobbyRefresh(GameLogic::Protocol_LobbyRefresh& p, DanBias::NetworkSession* c)
|
||||
{
|
||||
double now = this->timer.getElapsedSeconds() + c->lastPoll;
|
||||
|
||||
if(now > this->refreshFrequency)
|
||||
{
|
||||
c->lastPoll = (float)now;
|
||||
}
|
||||
}
|
||||
|
||||
void GameLobby::LobbyLogin(GameLogic::Protocol_LobbyLogin& p, DanBias::NetworkSession* c)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void GameLobby::LobbyJoin(GameLogic::Protocol_LobbyJoin& p, DanBias::NetworkSession* 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -29,6 +29,7 @@ void ClientFnc()
|
|||
//gameDesc.IP = "193.11.184.31";
|
||||
//gameDesc.IP = "194.47.150.56";
|
||||
gameDesc.IP = "127.0.0.1";
|
||||
//gameDesc.IP = "194.47.150.184";
|
||||
|
||||
if( DanBias::DanBiasGame::Initiate(gameDesc) == DanBias::DanBiasClientReturn_Sucess)
|
||||
{
|
||||
|
|
|
@ -177,9 +177,6 @@
|
|||
<ProjectReference Include="..\DanBiasGame\DanBiasGame.vcxproj">
|
||||
<Project>{2a1bc987-af42-4500-802d-89cd32fc1309}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\DanBiasServer\DanBiasServer.vcxproj">
|
||||
<Project>{52380daa-0f4a-4d97-8e57-98df39319caf}</Project>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
#ifndef MISC_DYNAMIC_ARRAY_H
|
||||
#define MISC_DYNAMIC_ARRAY_H
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
namespace Utility
|
||||
{
|
||||
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 Start();
|
||||
OYSTER_THREAD_ERROR Stop();
|
||||
OYSTER_THREAD_ERROR Pause();
|
||||
OYSTER_THREAD_ERROR Pause(int mSec);
|
||||
OYSTER_THREAD_ERROR Stop(int msec);
|
||||
OYSTER_THREAD_ERROR Resume();
|
||||
OYSTER_THREAD_ERROR SetWorker(IThreadObject* worker = 0);
|
||||
OYSTER_THREAD_ERROR SetWorker(ThreadFnc worker = 0);
|
||||
|
|
|
@ -229,6 +229,7 @@ OYSTER_THREAD_ERROR OysterThread::Create(IThreadObject* worker, bool start, bool
|
|||
{
|
||||
if(!this->privateData) this->privateData = new PrivateData();
|
||||
|
||||
if(this->privateData->data->isCreated) return OYSTER_THREAD_ERROR_ThreadAlreadyCreated;
|
||||
OwnerContainer c;
|
||||
c.type = Oyster::Callback::CallbackType_Object;
|
||||
c.value = worker;
|
||||
|
@ -257,15 +258,11 @@ OYSTER_THREAD_ERROR OysterThread::Start()
|
|||
return OYSTER_THREAD_ERROR_SUCCESS;
|
||||
}
|
||||
OYSTER_THREAD_ERROR OysterThread::Stop()
|
||||
{
|
||||
return this->Terminate();
|
||||
}
|
||||
OYSTER_THREAD_ERROR OysterThread::Pause()
|
||||
{
|
||||
this->privateData->data->threadData->state = OYSTER_THREAD_STATE_IDLE;
|
||||
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;
|
||||
return OYSTER_THREAD_ERROR_SUCCESS;
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
/////////////////////////////////////////////
|
||||
|
||||
#include "IQueue.h"
|
||||
#include <mutex>
|
||||
|
||||
namespace Utility
|
||||
{
|
||||
|
@ -20,6 +21,7 @@ namespace Utility
|
|||
{
|
||||
public:
|
||||
ThreadSafeQueue<Type>();
|
||||
ThreadSafeQueue<Type>(const ThreadSafeQueue<Type>& obj);
|
||||
virtual ~ThreadSafeQueue<Type>();
|
||||
|
||||
virtual void Push( Type item );
|
||||
|
@ -64,6 +66,12 @@ namespace Utility
|
|||
|
||||
}
|
||||
|
||||
template < typename Type >
|
||||
ThreadSafeQueue<Type>::ThreadSafeQueue(const ThreadSafeQueue<Type>& obj)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
template < typename Type >
|
||||
ThreadSafeQueue<Type>::~ThreadSafeQueue()
|
||||
{
|
||||
|
|
|
@ -6,12 +6,7 @@
|
|||
|
||||
#include <string>
|
||||
//#include <vld.h>
|
||||
|
||||
#ifdef CUSTOM_NET_PROTOCOL_EXPORT
|
||||
#define NET_PROTOCOL_EXPORT __declspec(dllexport)
|
||||
#else
|
||||
#define NET_PROTOCOL_EXPORT __declspec(dllimport)
|
||||
#endif
|
||||
#include "NetworkAPI_Preprocessor.h"
|
||||
|
||||
namespace Oyster
|
||||
{
|
||||
|
@ -78,7 +73,7 @@ namespace Oyster
|
|||
virtual CustomNetProtocol* GetProtocol() = 0;
|
||||
};
|
||||
|
||||
class NET_PROTOCOL_EXPORT CustomNetProtocol
|
||||
class NET_API_EXPORT CustomNetProtocol
|
||||
{
|
||||
public:
|
||||
CustomNetProtocol();
|
||||
|
|
|
@ -105,7 +105,7 @@
|
|||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>CUSTOM_NET_PROTOCOL_EXPORT;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>NETWORKAPI_EXPORT;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
|
@ -119,7 +119,7 @@
|
|||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>CUSTOM_NET_PROTOCOL_EXPORT;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>NETWORKAPI_EXPORT;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
|
@ -135,7 +135,7 @@
|
|||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>CUSTOM_NET_PROTOCOL_EXPORT;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>NETWORKAPI_EXPORT;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
|
@ -153,7 +153,7 @@
|
|||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>CUSTOM_NET_PROTOCOL_EXPORT;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>NETWORKAPI_EXPORT;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
|
@ -167,13 +167,16 @@
|
|||
<ClCompile Include="CustomNetProtocol.cpp" />
|
||||
<ClCompile Include="NetworkServer.cpp" />
|
||||
<ClCompile Include="NetworkClient.cpp" />
|
||||
<ClCompile Include="NetworkSession.cpp" />
|
||||
<ClCompile Include="Translator.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="CustomNetProtocol.h" />
|
||||
<ClInclude Include="NetworkCallbackHelper.h" />
|
||||
<ClInclude Include="NetworkAPI_Preprocessor.h" />
|
||||
<ClInclude Include="NetworkServer.h" />
|
||||
<ClInclude Include="NetworkClient.h" />
|
||||
<ClInclude Include="NetworkServerEventStruct.h" />
|
||||
<ClInclude Include="NetworkSession.h" />
|
||||
<ClInclude Include="Translator.h" />
|
||||
</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 "CustomNetProtocol.h"
|
||||
#include "NetworkSession.h"
|
||||
|
||||
#include "../NetworkDependencies/Connection.h"
|
||||
#include "../NetworkDependencies/PostBox.h"
|
||||
|
@ -19,73 +20,53 @@
|
|||
using namespace Oyster::Network;
|
||||
using namespace Oyster::Thread;
|
||||
using namespace Utility::DynamicMemory;
|
||||
using namespace Utility::Container;
|
||||
|
||||
/*************************************
|
||||
PrivateData
|
||||
*************************************/
|
||||
struct ClientDataContainer
|
||||
{
|
||||
typedef NetworkClient::ClientEventArgs CEA;
|
||||
struct NetDataContainer : public IThreadObject
|
||||
{ //This struct is contained within a smart pointer. To avoide dependencies in link its implemented here..
|
||||
NetworkSession *owner;
|
||||
NetworkClient *parent;
|
||||
Connection connection;
|
||||
|
||||
SmartPointer<IPostBox<CustomNetProtocol>> sendPostBox;
|
||||
|
||||
RecieverObject recvObj;
|
||||
NetworkProtocolCallbackType callbackType;
|
||||
|
||||
Oyster::Thread::OysterThread thread;
|
||||
std::mutex recvObjMutex;
|
||||
std::mutex postBoxMutex;
|
||||
|
||||
Translator translator;
|
||||
OysterThread thread;
|
||||
|
||||
|
||||
//Message queue for sending and recieving
|
||||
ThreadSafeQueue<CustomNetProtocol> sendQueue;
|
||||
ThreadSafeQueue<NetEvent<NetworkClient*, NetworkClient::ClientEventArgs>> recieveQueue;
|
||||
|
||||
//ID
|
||||
static unsigned int currID;
|
||||
const unsigned int ID;
|
||||
|
||||
ClientDataContainer(IThreadObject* o)
|
||||
: ID(currID++)
|
||||
NetDataContainer()
|
||||
: 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();
|
||||
callbackType = NetworkProtocolCallbackType_Unknown;
|
||||
sendPostBox = new PostBox<CustomNetProtocol>();
|
||||
connection.InitiateClient();
|
||||
connection.SetBlockingMode(false);
|
||||
this->thread.Create(this, true);
|
||||
this->thread.SetPriority(Oyster::Thread::OYSTER_THREAD_PRIORITY_1);
|
||||
}
|
||||
~ClientDataContainer()
|
||||
NetDataContainer(const NetDataContainer& obj)
|
||||
:ID(obj.ID) { }
|
||||
~NetDataContainer()
|
||||
{
|
||||
connection.Disconnect();
|
||||
thread.Stop();
|
||||
callbackType = NetworkProtocolCallbackType_Unknown;
|
||||
|
||||
ShutdownWinSock();
|
||||
this->connection.Disconnect();
|
||||
this->thread.Terminate();
|
||||
this->owner = 0;
|
||||
this->parent = 0;
|
||||
}
|
||||
|
||||
};
|
||||
unsigned int ClientDataContainer::currID = 0;
|
||||
|
||||
|
||||
struct NetworkClient::PrivateData : public IThreadObject
|
||||
{
|
||||
Utility::DynamicMemory::SmartPointer<ClientDataContainer> data;
|
||||
|
||||
PrivateData() { this->data = new ClientDataContainer(this); }
|
||||
PrivateData(unsigned int socket) { this->data = new ClientDataContainer(this, socket); }
|
||||
~PrivateData() { }
|
||||
|
||||
bool DoWork()
|
||||
bool DoWork() override
|
||||
{
|
||||
if(!this->data) return false;
|
||||
if(!this->data->connection.IsConnected()) return false;
|
||||
if(!this->connection.IsConnected()) return false;
|
||||
|
||||
Send();
|
||||
Recv();
|
||||
|
@ -93,45 +74,25 @@ struct NetworkClient::PrivateData : public IThreadObject
|
|||
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 errorCode = 0;
|
||||
if(!data) return -1;
|
||||
|
||||
this->data->postBoxMutex.lock();
|
||||
if(this->data->sendPostBox->IsFull())
|
||||
if(!this->sendQueue.IsEmpty())
|
||||
{
|
||||
SmartPointer<OysterByte> temp = new OysterByte();
|
||||
this->data->translator.Pack(temp, this->data->sendPostBox->FetchMessage());
|
||||
errorCode = this->data->connection.Send(temp);
|
||||
CustomNetProtocol p = this->sendQueue.Pop();
|
||||
this->translator.Pack(temp, p);
|
||||
errorCode = this->connection.Send(temp);
|
||||
if(errorCode != 0)
|
||||
{
|
||||
//Failed
|
||||
this->data->connection.Disconnect();
|
||||
|
||||
this->data->recvObjMutex.lock();
|
||||
if(this->data->callbackType == NetworkProtocolCallbackType_Function)
|
||||
{
|
||||
this->data->recvObj.protocolRecieverFnc();
|
||||
}
|
||||
else if(this->data->callbackType == NetworkProtocolCallbackType_Object)
|
||||
{
|
||||
this->data->recvObj.protocolRecievedObject->Disconnected();
|
||||
}
|
||||
this->data->recvObjMutex.unlock();
|
||||
CEA parg;
|
||||
parg.type = CEA::EventType_ProtocolFailedToSend;
|
||||
parg.data.protocol = p;
|
||||
NetEvent<NetworkClient*, CEA> e = { this->parent, parg };
|
||||
this->recieveQueue.Push(e);
|
||||
}
|
||||
}
|
||||
this->data->postBoxMutex.unlock();
|
||||
|
||||
return errorCode;
|
||||
}
|
||||
|
@ -141,105 +102,129 @@ struct NetworkClient::PrivateData : public IThreadObject
|
|||
int errorCode = -1;
|
||||
|
||||
OysterByte temp = OysterByte();
|
||||
errorCode = this->data->connection.Recieve(temp);
|
||||
errorCode = this->connection.Recieve(temp);
|
||||
|
||||
if(errorCode == 0 && temp.GetSize())
|
||||
{
|
||||
CustomNetProtocol protocol;
|
||||
bool ok = this->data->translator.Unpack(protocol, temp);
|
||||
bool ok = this->translator.Unpack(protocol, temp);
|
||||
|
||||
//Check if the protocol was unpacked correctly
|
||||
if(ok)
|
||||
{
|
||||
this->data->recvObjMutex.lock();
|
||||
if(this->data->callbackType == NetworkProtocolCallbackType_Function)
|
||||
{
|
||||
this->data->recvObj.protocolRecieverFnc(protocol);
|
||||
}
|
||||
else if(this->data->callbackType == NetworkProtocolCallbackType_Object)
|
||||
{
|
||||
this->data->recvObj.protocolRecievedObject->NetworkCallback(protocol);
|
||||
}
|
||||
this->data->recvObjMutex.unlock();
|
||||
CEA parg;
|
||||
parg.type = CEA::EventType_ProtocolRecieved;
|
||||
parg.data.protocol = protocol;
|
||||
NetEvent<NetworkClient*, NetworkClient::ClientEventArgs> e = { this->parent, parg };
|
||||
this->recieveQueue.Push(e);
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
struct NetworkClient::PrivateData
|
||||
{
|
||||
SmartPointer<NetDataContainer> dat;
|
||||
|
||||
public:
|
||||
PrivateData()
|
||||
{ this->dat = new NetDataContainer(); }
|
||||
PrivateData(const PrivateData& obj)
|
||||
{ this->dat = obj.dat; }
|
||||
~PrivateData()
|
||||
{ this->dat = 0; }
|
||||
};
|
||||
unsigned int NetDataContainer::currID = 0;
|
||||
|
||||
/*************************************
|
||||
NetworkClient
|
||||
*************************************/
|
||||
|
||||
NetworkClient::NetworkClient()
|
||||
{
|
||||
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);
|
||||
}
|
||||
: privateData(0)
|
||||
{ }
|
||||
|
||||
NetworkClient::NetworkClient(const NetworkClient& obj)
|
||||
{
|
||||
this->privateData = new PrivateData(*obj.privateData);
|
||||
if(obj.privateData) this->privateData = new PrivateData(*obj.privateData);
|
||||
else this->privateData = 0;
|
||||
}
|
||||
|
||||
NetworkClient& NetworkClient::operator =(const NetworkClient& obj)
|
||||
{
|
||||
delete privateData;
|
||||
this->privateData = new PrivateData(*obj.privateData);
|
||||
this->privateData = 0;
|
||||
if(obj.privateData) this->privateData = new PrivateData(*obj.privateData);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
NetworkClient::~NetworkClient()
|
||||
{
|
||||
if(privateData)
|
||||
if(this->privateData)
|
||||
{
|
||||
delete privateData;
|
||||
privateData = NULL;
|
||||
delete this->privateData;
|
||||
this->privateData = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
bool NetworkClient::operator ==(const NetworkClient& obj)
|
||||
{
|
||||
return (this->privateData->dat->ID == obj.privateData->dat->ID);
|
||||
}
|
||||
|
||||
bool NetworkClient::operator ==(const int& ID)
|
||||
{
|
||||
return this->privateData->dat->ID == ID;
|
||||
}
|
||||
|
||||
void NetworkClient::ProcessMessages()
|
||||
{
|
||||
while (!this->privateData->dat->recieveQueue.IsEmpty())
|
||||
{
|
||||
if(this->privateData->dat->owner)
|
||||
{
|
||||
this->privateData->dat->owner->ClientEventCallback(this->privateData->dat->recieveQueue.Pop());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool NetworkClient::Connect(int socket)
|
||||
{
|
||||
if(this->IsConnected()) return true;
|
||||
if(this->privateData) return false;
|
||||
if(!this->privateData) this->privateData = new PrivateData();
|
||||
|
||||
int result = this->privateData->dat->connection.Connect(socket, true);
|
||||
|
||||
//Connect has succeeded
|
||||
if(result == 0) return true;
|
||||
|
||||
//Connect has failed
|
||||
return false;
|
||||
}
|
||||
|
||||
bool NetworkClient::Connect(unsigned short port, const char serverIP[])
|
||||
{
|
||||
privateData->data->connection.SetBlockingMode(true);
|
||||
int result = this->privateData->data->connection.Connect(port, serverIP);
|
||||
if(this->IsConnected()) return false;
|
||||
if(this->privateData) return false;
|
||||
if(!this->privateData) this->privateData = new PrivateData();
|
||||
|
||||
int result = this->privateData->dat->connection.Connect(port, serverIP, false);
|
||||
|
||||
//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;
|
||||
}
|
||||
|
||||
|
||||
if(result == 0) return true;
|
||||
|
||||
//Connect has failed
|
||||
return false;
|
||||
|
@ -247,46 +232,35 @@ bool NetworkClient::Connect(unsigned short port, const char serverIP[])
|
|||
|
||||
void NetworkClient::Disconnect()
|
||||
{
|
||||
privateData->data->connection.Disconnect();
|
||||
privateData->data->thread.Terminate();
|
||||
}
|
||||
|
||||
bool NetworkClient::IsConnected()
|
||||
{
|
||||
return privateData->data->connection.IsConnected();
|
||||
privateData->dat->connection.Disconnect();
|
||||
privateData->dat->thread.Terminate();
|
||||
}
|
||||
|
||||
void NetworkClient::Send(CustomProtocolObject& protocol)
|
||||
{
|
||||
this->privateData->Send(protocol.GetProtocol());
|
||||
this->privateData->dat->sendQueue.Push(*protocol.GetProtocol());
|
||||
}
|
||||
|
||||
void NetworkClient::Send(CustomNetProtocol* protocol)
|
||||
{
|
||||
this->privateData->Send(protocol);
|
||||
this->privateData->dat->sendQueue.Push(*protocol);
|
||||
}
|
||||
|
||||
void NetworkClient::SetRecieverObject(RecieverObject recvObj, NetworkProtocolCallbackType type)
|
||||
void NetworkClient::SetOwner(NetworkSession* owner)
|
||||
{
|
||||
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();
|
||||
this->privateData->dat->owner = owner;
|
||||
}
|
||||
|
||||
bool NetworkClient::operator ==(const NetworkClient& obj)
|
||||
bool NetworkClient::IsConnected()
|
||||
{
|
||||
return (this->privateData->data->ID == obj.privateData->data->ID);
|
||||
}
|
||||
|
||||
bool NetworkClient::operator ==(const int& ID)
|
||||
{
|
||||
return this->privateData->data->ID == ID;
|
||||
if(!this->privateData) return false;
|
||||
return privateData->dat->connection.IsConnected();
|
||||
}
|
||||
|
||||
int NetworkClient::GetID() const
|
||||
{
|
||||
return this->privateData->data->ID;
|
||||
return this->privateData->dat->ID;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,59 +1,101 @@
|
|||
#ifndef 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
|
||||
#define NET_PROTOCOL_EXPORT __declspec(dllexport)
|
||||
#else
|
||||
#define NET_PROTOCOL_EXPORT __declspec(dllimport)
|
||||
#endif
|
||||
|
||||
#include "NetworkCallbackHelper.h"
|
||||
//#include <vld.h>
|
||||
#include "CustomNetProtocol.h"
|
||||
#include "NetworkServerEventStruct.h"
|
||||
#include "NetworkAPI_Preprocessor.h"
|
||||
|
||||
namespace Oyster
|
||||
{
|
||||
namespace Network
|
||||
{
|
||||
class NetworkSession;
|
||||
|
||||
extern "C"
|
||||
{
|
||||
struct CustomProtocolObject;
|
||||
class NET_PROTOCOL_EXPORT NetworkClient
|
||||
class NET_API_EXPORT NetworkClient
|
||||
{
|
||||
public:
|
||||
NetworkClient();
|
||||
NetworkClient(unsigned int socket);
|
||||
NetworkClient(RecieverObject recvObj, NetworkProtocolCallbackType type);
|
||||
NetworkClient(RecieverObject recvObj, NetworkProtocolCallbackType type, unsigned int socket);
|
||||
NetworkClient(const NetworkClient& obj);
|
||||
struct ClientEventArgs
|
||||
{
|
||||
enum EventType
|
||||
{
|
||||
EventType_ProtocolFailedToRecieve, // No data
|
||||
EventType_ProtocolFailedToSend, // Data in data.protocol
|
||||
EventType_ProtocolRecieved, // Data in data.protocol
|
||||
EventType_Disconnect, // No data
|
||||
} type;
|
||||
|
||||
union EventData
|
||||
{
|
||||
struct { Oyster::Network::CustomNetProtocol protocol; };
|
||||
void * nothing;
|
||||
} data;
|
||||
};
|
||||
typedef void(*ClientEventFunction)(NetEvent<NetworkClient*, ClientEventArgs> e);
|
||||
|
||||
public:
|
||||
NetworkClient();
|
||||
NetworkClient(const NetworkClient& obj);
|
||||
NetworkClient& operator =(const NetworkClient& obj);
|
||||
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 int& ID);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
void ProcessMessages();
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
bool Connect(int socket);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
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;
|
||||
|
||||
private:
|
||||
struct PrivateData;
|
||||
PrivateData* privateData;
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,146 +23,50 @@ using namespace Oyster::Thread;
|
|||
|
||||
struct NetworkServer::PrivateData : public IThreadObject
|
||||
{
|
||||
PrivateData();
|
||||
~PrivateData();
|
||||
|
||||
bool Init(INIT_DESC& initDesc);
|
||||
bool Start();
|
||||
void Stop();
|
||||
void Shutdown();
|
||||
|
||||
void CheckForNewClient();
|
||||
public:
|
||||
PrivateData()
|
||||
: listener(0)
|
||||
, mainSession(0)
|
||||
, isInitiated(0)
|
||||
, isReleased(0)
|
||||
, isRunning(0)
|
||||
{ }
|
||||
~PrivateData()
|
||||
{ }
|
||||
|
||||
bool DoWork();
|
||||
|
||||
//
|
||||
public:
|
||||
IListener* listener;
|
||||
INIT_DESC initDesc;
|
||||
bool started;
|
||||
|
||||
//Postbox for new clients
|
||||
PostBox<int> postBox;
|
||||
|
||||
//Server thread
|
||||
OysterThread thread;
|
||||
PostBox<int> postBox; //Postbox for new clients
|
||||
OysterThread thread; //Server thread
|
||||
NetworkSession *mainSession;
|
||||
Utility::Container::ThreadSafeQueue<NetworkClient> clientQueue;
|
||||
|
||||
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()
|
||||
bool NetworkServer::PrivateData::DoWork()
|
||||
{
|
||||
/** Check for new clients **/
|
||||
if(postBox.IsFull())
|
||||
{
|
||||
int clientSocketNum = postBox.FetchMessage();
|
||||
|
||||
//Safety check that is probably not needed.
|
||||
if(clientSocketNum == -1)
|
||||
{
|
||||
return;
|
||||
//Something went wrong somewhere... do we care?
|
||||
}
|
||||
|
||||
//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);
|
||||
}
|
||||
|
||||
Oyster::Network::NetworkClient client;
|
||||
client.Connect(clientSocketNum);
|
||||
if(this->mainSession)
|
||||
this->clientQueue.Push(client);
|
||||
}
|
||||
}
|
||||
|
||||
bool NetworkServer::PrivateData::DoWork()
|
||||
{
|
||||
CheckForNewClient();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -173,48 +77,142 @@ bool NetworkServer::PrivateData::DoWork()
|
|||
|
||||
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()
|
||||
{
|
||||
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))
|
||||
//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(!((Listener*)this->privateData->listener)->Init(port, false))
|
||||
{
|
||||
return NetworkServer::ServerReturnCode_Error;
|
||||
}
|
||||
|
||||
if(this->privateData->thread.Create(this->privateData, false) == OYSTER_THREAD_ERROR_FAILED)
|
||||
{
|
||||
return NetworkServer::ServerReturnCode_Error;
|
||||
}
|
||||
|
||||
this->privateData->isInitiated = true;
|
||||
this->privateData->isReleased = false;
|
||||
this->privateData->mainSession = 0;
|
||||
return NetworkServer::ServerReturnCode_Sucess;
|
||||
}
|
||||
|
||||
bool NetworkServer::Start()
|
||||
NetworkServer::ServerReturnCode NetworkServer::Start()
|
||||
{
|
||||
if(!privateData->Start())
|
||||
//Start listener
|
||||
if(!((Listener*)this->privateData->listener)->Start())
|
||||
{
|
||||
return false;
|
||||
return NetworkServer::ServerReturnCode_Error;
|
||||
}
|
||||
|
||||
return true;
|
||||
if(this->privateData->thread.Start() == OYSTER_THREAD_ERROR_FAILED)
|
||||
{
|
||||
return NetworkServer::ServerReturnCode_Error;
|
||||
}
|
||||
|
||||
this->privateData->isRunning = true;
|
||||
return NetworkServer::ServerReturnCode_Sucess;
|
||||
}
|
||||
|
||||
void NetworkServer::Stop()
|
||||
{
|
||||
privateData->Stop();
|
||||
if(this->privateData->listener)
|
||||
{
|
||||
((Listener*)this->privateData->listener)->Stop();
|
||||
}
|
||||
|
||||
this->privateData->thread.Stop();
|
||||
|
||||
this->privateData->isRunning = false;
|
||||
}
|
||||
|
||||
void NetworkServer::Shutdown()
|
||||
{
|
||||
privateData->Shutdown();
|
||||
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;
|
||||
}
|
||||
|
||||
void NetworkServer::ProcessConnectedClients()
|
||||
{
|
||||
while(!this->privateData->clientQueue.IsEmpty())
|
||||
{
|
||||
if(this->privateData->mainSession) this->privateData->mainSession->Attach(this->privateData->clientQueue.Pop());
|
||||
}
|
||||
}
|
||||
|
||||
void NetworkServer::SetSession(NetworkSession const* mainSession)
|
||||
{
|
||||
this->privateData->mainSession = const_cast<NetworkSession*>(mainSession);
|
||||
}
|
||||
|
||||
NetworkSession const* NetworkServer::GetMainSession()
|
||||
{
|
||||
return this->privateData->mainSession;
|
||||
}
|
||||
|
||||
NetworkSession const* NetworkServer::ReleaseMainSessionSession()
|
||||
{
|
||||
NetworkSession const * temp;
|
||||
temp = this->privateData->mainSession;
|
||||
this->privateData->mainSession = 0;
|
||||
return temp;
|
||||
}
|
||||
|
||||
bool NetworkServer::IsStarted() const
|
||||
{
|
||||
return privateData->started;
|
||||
return this->privateData->isRunning;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
#ifndef 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 "NetworkCallbackHelper.h"
|
||||
#include "NetworkSession.h"
|
||||
#include <vld.h>
|
||||
|
||||
namespace Oyster
|
||||
|
@ -21,27 +18,68 @@ namespace Oyster
|
|||
{
|
||||
extern "C"
|
||||
{
|
||||
class NET_PROTOCOL_EXPORT NetworkServer
|
||||
class NET_API_EXPORT NetworkServer
|
||||
{
|
||||
public:
|
||||
struct INIT_DESC
|
||||
enum ServerReturnCode
|
||||
{
|
||||
unsigned short port; //Port the server should be accepting clients on.
|
||||
|
||||
NetworkClientCallbackType callbackType; //The recieverObject type. Function or object.
|
||||
RecieverObject recvObj; //The functions that is called when a new client has connected.
|
||||
ServerReturnCode_Error,
|
||||
ServerReturnCode_Sucess
|
||||
};
|
||||
|
||||
public:
|
||||
NetworkServer();
|
||||
NetworkServer(const NetworkServer&);
|
||||
const NetworkServer& operator=(const 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();
|
||||
|
||||
/** Shutdown the server and return all resources.
|
||||
*/
|
||||
void Shutdown();
|
||||
|
||||
/** Parses asynchronous connected clients.
|
||||
*/
|
||||
void 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* ReleaseMainSessionSession();
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
bool IsStarted() const;
|
||||
|
||||
|
||||
private:
|
||||
struct 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,184 @@
|
|||
/////////////////////////////////////////////////////////////////////
|
||||
// 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 Oyster::Network;
|
||||
|
||||
|
||||
struct NetworkSession::PrivateSessionData
|
||||
{
|
||||
Utility::DynamicMemory::DynamicArray<NetworkClient> 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(0)
|
||||
{}
|
||||
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;
|
||||
}
|
||||
|
||||
void NetworkSession::ProcessClients()
|
||||
{
|
||||
for (unsigned int i = 0; i < this->data->clients.Size(); i++)
|
||||
{
|
||||
this->data->clients[i].ProcessMessages();
|
||||
}
|
||||
}
|
||||
|
||||
bool NetworkSession::Attach(NetworkClient 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++;
|
||||
|
||||
this->data->clientListLock.unlock();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
NetworkClient NetworkSession::Detach(const NetworkClient& client)
|
||||
{
|
||||
NetworkClient val;
|
||||
|
||||
this->data->clientListLock.lock();
|
||||
|
||||
for (unsigned int i = 0; i < this->data->clients.Size(); i++)
|
||||
{
|
||||
if(this->data->clients[0].GetID() == client.GetID())
|
||||
{
|
||||
val = this->data->clients[i];
|
||||
this->data->clients[i] = NetworkClient();
|
||||
this->data->clientCount--;
|
||||
}
|
||||
}
|
||||
|
||||
this->data->clientListLock.unlock();
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
NetworkClient NetworkSession::Detach(short ID)
|
||||
{
|
||||
NetworkClient val;
|
||||
|
||||
this->data->clientListLock.lock();
|
||||
|
||||
for (unsigned int i = 0; i < this->data->clients.Size(); i++)
|
||||
{
|
||||
if(this->data->clients[0].GetID() == ID)
|
||||
{
|
||||
val = this->data->clients[i];
|
||||
this->data->clients[i] = NetworkClient();
|
||||
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++)
|
||||
{
|
||||
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].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(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();
|
||||
}
|
||||
|
||||
this->data->clients.Clear();
|
||||
this->data->clientCount = 0;
|
||||
|
||||
this->data->clientListLock.unlock();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,83 @@
|
|||
/////////////////////////////////////////////////////////////////////
|
||||
// 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"
|
||||
|
||||
namespace Oyster
|
||||
{
|
||||
namespace Network
|
||||
{
|
||||
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();
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
bool Attach(NetworkClient client);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
NetworkClient Detach(const NetworkClient& client);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
NetworkClient Detach(short ID);
|
||||
|
||||
/** Send a message to all clients in this session
|
||||
* @param message The message
|
||||
*/
|
||||
bool Send(Oyster::Network::CustomNetProtocol& message);
|
||||
|
||||
/** Send a message to a specific client in this session
|
||||
* @param message The message
|
||||
*/
|
||||
bool Send(Oyster::Network::CustomNetProtocol& protocol, int ID);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
void SetOwner(NetworkSession* owner);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
virtual void ClientEventCallback(NetEvent<NetworkClient*, NetworkClient::ClientEventArgs> e) = 0;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
virtual void ClientConnectedEvent(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 "../../Misc/Utilities.h"
|
||||
#include "../NetworkDependencies/Messages/MessageHeader.h"
|
||||
#include "../NetworkDependencies/OysterByte.h"
|
||||
|
||||
|
|
|
@ -27,13 +27,7 @@
|
|||
"100F"
|
||||
*/
|
||||
|
||||
#ifdef CUSTOM_NET_PROTOCOL_EXPORT
|
||||
#define NET_PROTOCOL_EXPORT __declspec(dllexport)
|
||||
#else
|
||||
#define NET_PROTOCOL_EXPORT __declspec(dllimport)
|
||||
#endif
|
||||
|
||||
#include "../../Misc/Utilities.h"
|
||||
#include "NetworkAPI_Preprocessor.h"
|
||||
|
||||
namespace Oyster
|
||||
{
|
||||
|
@ -43,7 +37,8 @@ namespace Oyster
|
|||
{
|
||||
class OysterByte;
|
||||
class CustomNetProtocol;
|
||||
class NET_PROTOCOL_EXPORT Translator
|
||||
|
||||
class NET_API_EXPORT Translator
|
||||
{
|
||||
public:
|
||||
Translator ();
|
||||
|
|
|
@ -40,7 +40,18 @@ Connection::~Connection()
|
|||
CloseSocket( this->socket );
|
||||
}
|
||||
|
||||
int Connection::Connect(unsigned short port , const char serverName[])
|
||||
int Connection::Connect(int socket, bool blocking)
|
||||
{
|
||||
this->socket = socket;
|
||||
this->stillSending = true;
|
||||
this->closed = false;
|
||||
|
||||
SetBlockingMode(blocking);
|
||||
//connection succesfull!
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Connection::Connect(unsigned short port , const char serverName[], bool blocking)
|
||||
{
|
||||
struct hostent *hostEnt;
|
||||
if((hostEnt = gethostbyname(serverName)) == NULL)
|
||||
|
@ -61,6 +72,8 @@ int Connection::Connect(unsigned short port , const char serverName[])
|
|||
closed = false;
|
||||
stillSending = true;
|
||||
|
||||
SetBlockingMode(blocking);
|
||||
|
||||
//connection succesfull!
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -27,7 +27,8 @@ namespace Oyster
|
|||
virtual int Recieve( OysterByte &bytes );
|
||||
|
||||
virtual int Disconnect();
|
||||
virtual int Connect( unsigned short port , const char serverName[] );
|
||||
virtual int Connect(int socket, bool blocking = false);
|
||||
virtual int Connect(unsigned short port , const char serverName[], bool blocking = false);
|
||||
|
||||
virtual int Listen();
|
||||
|
||||
|
|
|
@ -120,7 +120,7 @@ void Listener::StopListen()
|
|||
this->isListening = false;
|
||||
Connection c;
|
||||
c.InitiateClient();
|
||||
c.Connect(this->port, "127.0.0.1");
|
||||
c.Connect(this->port, "127.0.0.1", false);
|
||||
}
|
||||
}
|
||||
bool Listener::DoWork()
|
||||
|
|
Loading…
Reference in New Issue