GL - Merge client with gameserver
This commit is contained in:
commit
0ffe26c134
|
@ -1,10 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<diagram program="umlet" version="12.1">
|
||||
<diagram program="umlet" version="12.2">
|
||||
<zoom_level>11</zoom_level>
|
||||
<element>
|
||||
<type>com.umlet.element.Class</type>
|
||||
<coordinates>
|
||||
<x>726</x>
|
||||
<x>847</x>
|
||||
<y>363</y>
|
||||
<w>132</w>
|
||||
<h>33</h>
|
||||
|
@ -15,7 +15,7 @@
|
|||
<element>
|
||||
<type>com.umlet.element.Class</type>
|
||||
<coordinates>
|
||||
<x>440</x>
|
||||
<x>561</x>
|
||||
<y>363</y>
|
||||
<w>132</w>
|
||||
<h>33</h>
|
||||
|
@ -26,19 +26,19 @@
|
|||
<element>
|
||||
<type>com.umlet.element.Class</type>
|
||||
<coordinates>
|
||||
<x>550</x>
|
||||
<y>286</y>
|
||||
<x>671</x>
|
||||
<y>209</y>
|
||||
<w>132</w>
|
||||
<h>33</h>
|
||||
</coordinates>
|
||||
<panel_attributes>Physics / Math</panel_attributes>
|
||||
<panel_attributes>Physics</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Class</type>
|
||||
<coordinates>
|
||||
<x>737</x>
|
||||
<y>176</y>
|
||||
<x>858</x>
|
||||
<y>132</y>
|
||||
<w>121</w>
|
||||
<h>33</h>
|
||||
</coordinates>
|
||||
|
@ -48,8 +48,8 @@
|
|||
<element>
|
||||
<type>com.umlet.element.Class</type>
|
||||
<coordinates>
|
||||
<x>363</x>
|
||||
<y>286</y>
|
||||
<x>484</x>
|
||||
<y>209</y>
|
||||
<w>154</w>
|
||||
<h>33</h>
|
||||
</coordinates>
|
||||
|
@ -59,8 +59,8 @@
|
|||
<element>
|
||||
<type>com.umlet.element.Class</type>
|
||||
<coordinates>
|
||||
<x>385</x>
|
||||
<y>176</y>
|
||||
<x>506</x>
|
||||
<y>132</y>
|
||||
<w>121</w>
|
||||
<h>33</h>
|
||||
</coordinates>
|
||||
|
@ -70,8 +70,8 @@
|
|||
<element>
|
||||
<type>com.umlet.element.Class</type>
|
||||
<coordinates>
|
||||
<x>550</x>
|
||||
<y>154</y>
|
||||
<x>671</x>
|
||||
<y>132</y>
|
||||
<w>132</w>
|
||||
<h>33</h>
|
||||
</coordinates>
|
||||
|
@ -81,7 +81,7 @@
|
|||
<element>
|
||||
<type>com.umlet.element.Class</type>
|
||||
<coordinates>
|
||||
<x>583</x>
|
||||
<x>704</x>
|
||||
<y>363</y>
|
||||
<w>132</w>
|
||||
<h>33</h>
|
||||
|
@ -92,86 +92,64 @@
|
|||
<element>
|
||||
<type>com.umlet.element.Class</type>
|
||||
<coordinates>
|
||||
<x>550</x>
|
||||
<y>198</y>
|
||||
<w>132</w>
|
||||
<h>33</h>
|
||||
</coordinates>
|
||||
<panel_attributes>Threading</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Class</type>
|
||||
<coordinates>
|
||||
<x>550</x>
|
||||
<x>495</x>
|
||||
<y>55</y>
|
||||
<w>132</w>
|
||||
<w>176</w>
|
||||
<h>44</h>
|
||||
</coordinates>
|
||||
<panel_attributes>DanBias
|
||||
<panel_attributes>DanBiasClientLauncher
|
||||
bg=green</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>759</x>
|
||||
<y>176</y>
|
||||
<x>880</x>
|
||||
<y>132</y>
|
||||
<w>54</w>
|
||||
<h>208</h>
|
||||
<h>252</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=<-</panel_attributes>
|
||||
<additional_attributes>33;187;33;165;33;33</additional_attributes>
|
||||
<additional_attributes>33;231;33;209;33;33</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>462</x>
|
||||
<y>176</y>
|
||||
<x>583</x>
|
||||
<y>132</y>
|
||||
<w>351</w>
|
||||
<h>208</h>
|
||||
<h>252</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=<-</panel_attributes>
|
||||
<additional_attributes>33;187;33;165;330;165;330;33</additional_attributes>
|
||||
<additional_attributes>33;231;33;209;330;209;330;33</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>407</x>
|
||||
<y>176</y>
|
||||
<x>528</x>
|
||||
<y>132</y>
|
||||
<w>54</w>
|
||||
<h>131</h>
|
||||
<h>98</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=<-</panel_attributes>
|
||||
<additional_attributes>33;110;33;33</additional_attributes>
|
||||
<additional_attributes>33;77;33;33</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>649</x>
|
||||
<y>176</y>
|
||||
<w>153</w>
|
||||
<h>142</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=<-</panel_attributes>
|
||||
<additional_attributes>33;121;132;121;132;33</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>473</x>
|
||||
<y>143</y>
|
||||
<x>594</x>
|
||||
<y>110</y>
|
||||
<w>98</w>
|
||||
<h>65</h>
|
||||
<h>54</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=<-</panel_attributes>
|
||||
<additional_attributes>77;33;44;33;44;44;33;44</additional_attributes>
|
||||
<additional_attributes>77;33;33;33</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>484</x>
|
||||
<y>264</y>
|
||||
<x>605</x>
|
||||
<y>187</y>
|
||||
<w>87</w>
|
||||
<h>54</h>
|
||||
</coordinates>
|
||||
|
@ -181,76 +159,54 @@ bg=green</panel_attributes>
|
|||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>616</x>
|
||||
<y>176</y>
|
||||
<x>737</x>
|
||||
<y>132</y>
|
||||
<w>197</w>
|
||||
<h>208</h>
|
||||
<h>252</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=<-</panel_attributes>
|
||||
<additional_attributes>33;187;33;165;176;165;176;33</additional_attributes>
|
||||
<additional_attributes>33;231;33;209;176;209;176;33</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>473</x>
|
||||
<y>165</y>
|
||||
<w>98</w>
|
||||
<h>65</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=<-</panel_attributes>
|
||||
<additional_attributes>77;44;44;44;44;33;33;33</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>649</x>
|
||||
<y>165</y>
|
||||
<x>770</x>
|
||||
<y>110</y>
|
||||
<w>109</w>
|
||||
<h>65</h>
|
||||
<h>54</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=<-</panel_attributes>
|
||||
<additional_attributes>33;44;66;44;66;33;88;33</additional_attributes>
|
||||
<additional_attributes>33;33;88;33</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>649</x>
|
||||
<y>143</y>
|
||||
<w>109</w>
|
||||
<h>65</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=<-</panel_attributes>
|
||||
<additional_attributes>33;33;66;33;66;44;88;44</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>649</x>
|
||||
<y>33</y>
|
||||
<w>164</w>
|
||||
<h>164</h>
|
||||
<x>880</x>
|
||||
<y>66</y>
|
||||
<w>54</w>
|
||||
<h>87</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=>-</panel_attributes>
|
||||
<additional_attributes>33;33;143;33;143;143</additional_attributes>
|
||||
<additional_attributes>33;33;33;66</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>407</x>
|
||||
<y>33</y>
|
||||
<w>164</w>
|
||||
<h>164</h>
|
||||
<x>528</x>
|
||||
<y>66</y>
|
||||
<w>54</w>
|
||||
<h>87</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=>-</panel_attributes>
|
||||
<additional_attributes>143;33;33;33;33;143</additional_attributes>
|
||||
<additional_attributes>33;33;33;66</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Package</type>
|
||||
<coordinates>
|
||||
<x>319</x>
|
||||
<x>440</x>
|
||||
<y>22</y>
|
||||
<w>550</w>
|
||||
<h>385</h>
|
||||
<h>396</h>
|
||||
</coordinates>
|
||||
<panel_attributes>GameEngine</panel_attributes>
|
||||
<additional_attributes/>
|
||||
|
@ -258,7 +214,7 @@ bg=green</panel_attributes>
|
|||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>759</x>
|
||||
<x>880</x>
|
||||
<y>363</y>
|
||||
<w>54</w>
|
||||
<h>164</h>
|
||||
|
@ -269,7 +225,7 @@ bg=green</panel_attributes>
|
|||
<element>
|
||||
<type>com.umlet.element.Package</type>
|
||||
<coordinates>
|
||||
<x>770</x>
|
||||
<x>891</x>
|
||||
<y>506</y>
|
||||
<w>319</w>
|
||||
<h>220</h>
|
||||
|
@ -280,7 +236,7 @@ bg=green</panel_attributes>
|
|||
<element>
|
||||
<type>com.umlet.element.Class</type>
|
||||
<coordinates>
|
||||
<x>781</x>
|
||||
<x>902</x>
|
||||
<y>539</y>
|
||||
<w>297</w>
|
||||
<h>176</h>
|
||||
|
@ -300,7 +256,7 @@ Release(resource :Model*) :void</panel_attributes>
|
|||
<element>
|
||||
<type>com.umlet.element.Package</type>
|
||||
<coordinates>
|
||||
<x>440</x>
|
||||
<x>561</x>
|
||||
<y>506</y>
|
||||
<w>308</w>
|
||||
<h>242</h>
|
||||
|
@ -311,7 +267,7 @@ Release(resource :Model*) :void</panel_attributes>
|
|||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>528</x>
|
||||
<x>649</x>
|
||||
<y>363</y>
|
||||
<w>142</w>
|
||||
<h>175</h>
|
||||
|
@ -322,7 +278,7 @@ Release(resource :Model*) :void</panel_attributes>
|
|||
<element>
|
||||
<type>com.umlet.element.Class</type>
|
||||
<coordinates>
|
||||
<x>451</x>
|
||||
<x>572</x>
|
||||
<y>539</y>
|
||||
<w>286</w>
|
||||
<h>198</h>
|
||||
|
@ -343,7 +299,7 @@ Enable(Enable :bool) :void</panel_attributes>
|
|||
<element>
|
||||
<type>com.umlet.element.Class</type>
|
||||
<coordinates>
|
||||
<x>330</x>
|
||||
<x>451</x>
|
||||
<y>363</y>
|
||||
<w>99</w>
|
||||
<h>33</h>
|
||||
|
@ -354,18 +310,18 @@ Enable(Enable :bool) :void</panel_attributes>
|
|||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>341</x>
|
||||
<y>176</y>
|
||||
<x>462</x>
|
||||
<y>132</y>
|
||||
<w>472</w>
|
||||
<h>208</h>
|
||||
<h>252</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=<-</panel_attributes>
|
||||
<additional_attributes>33;187;33;165;451;165;451;33</additional_attributes>
|
||||
<additional_attributes>33;231;33;209;451;209;451;33</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Package</type>
|
||||
<coordinates>
|
||||
<x>55</x>
|
||||
<x>176</x>
|
||||
<y>506</y>
|
||||
<w>374</w>
|
||||
<h>242</h>
|
||||
|
@ -376,7 +332,7 @@ Enable(Enable :bool) :void</panel_attributes>
|
|||
<element>
|
||||
<type>com.umlet.element.Class</type>
|
||||
<coordinates>
|
||||
<x>66</x>
|
||||
<x>187</x>
|
||||
<y>539</y>
|
||||
<w>352</w>
|
||||
<h>121</h>
|
||||
|
@ -393,7 +349,7 @@ Release(Resource :ResourceHandle*) :void</panel_attributes>
|
|||
<element>
|
||||
<type>com.umlet.element.Class</type>
|
||||
<coordinates>
|
||||
<x>66</x>
|
||||
<x>187</x>
|
||||
<y>693</y>
|
||||
<w>352</w>
|
||||
<h>44</h>
|
||||
|
@ -406,7 +362,7 @@ FMOD</panel_attributes>
|
|||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>209</x>
|
||||
<x>330</x>
|
||||
<y>627</y>
|
||||
<w>54</w>
|
||||
<h>87</h>
|
||||
|
@ -417,7 +373,7 @@ FMOD</panel_attributes>
|
|||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>165</x>
|
||||
<x>286</x>
|
||||
<y>363</y>
|
||||
<w>362</w>
|
||||
<h>175</h>
|
||||
|
@ -425,4 +381,60 @@ FMOD</panel_attributes>
|
|||
<panel_attributes>lt=<<.</panel_attributes>
|
||||
<additional_attributes>341;33;341;88;253;88;253;154;33;154</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Class</type>
|
||||
<coordinates>
|
||||
<x>781</x>
|
||||
<y>55</y>
|
||||
<w>198</w>
|
||||
<h>44</h>
|
||||
</coordinates>
|
||||
<panel_attributes>DanBiasServerLauncher
|
||||
bg=green</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Class</type>
|
||||
<coordinates>
|
||||
<x>671</x>
|
||||
<y>253</y>
|
||||
<w>132</w>
|
||||
<h>33</h>
|
||||
</coordinates>
|
||||
<panel_attributes>Math</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>770</x>
|
||||
<y>132</y>
|
||||
<w>153</w>
|
||||
<h>164</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=<-</panel_attributes>
|
||||
<additional_attributes>33;143;132;143;132;33</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Class</type>
|
||||
<coordinates>
|
||||
<x>682</x>
|
||||
<y>297</y>
|
||||
<w>99</w>
|
||||
<h>33</h>
|
||||
</coordinates>
|
||||
<panel_attributes>Misc</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>605</x>
|
||||
<y>198</y>
|
||||
<w>87</w>
|
||||
<h>98</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=<-</panel_attributes>
|
||||
<additional_attributes>66;77;44;77;44;33;33;33</additional_attributes>
|
||||
</element>
|
||||
</diagram>
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<diagram program="umlet" version="12.2">
|
||||
<zoom_level>10</zoom_level>
|
||||
</diagram>
|
|
@ -423,14 +423,14 @@ INetworkSession</panel_attributes>
|
|||
<element>
|
||||
<id>UMLClass</id>
|
||||
<coordinates>
|
||||
<x>170</x>
|
||||
<y>400</y>
|
||||
<w>130</w>
|
||||
<h>90</h>
|
||||
<x>150</x>
|
||||
<y>420</y>
|
||||
<w>160</w>
|
||||
<h>50</h>
|
||||
</coordinates>
|
||||
<panel_attributes>MapManager
|
||||
--
|
||||
Manages and makes sure maps are avalible to all clinents.
|
||||
Manages all map stuff.
|
||||
|
||||
elementstyle=wordwrap
|
||||
</panel_attributes>
|
|
@ -0,0 +1,402 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<diagram program="umlet" version="12.2">
|
||||
<zoom_level>8</zoom_level>
|
||||
<element>
|
||||
<id>UMLClass</id>
|
||||
<coordinates>
|
||||
<x>680</x>
|
||||
<y>592</y>
|
||||
<w>136</w>
|
||||
<h>40</h>
|
||||
</coordinates>
|
||||
<panel_attributes>CustomNetworkProtocol
|
||||
--</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<id>UMLClass</id>
|
||||
<coordinates>
|
||||
<x>560</x>
|
||||
<y>688</y>
|
||||
<w>152</w>
|
||||
<h>40</h>
|
||||
</coordinates>
|
||||
<panel_attributes>NetworkServer
|
||||
--
|
||||
elementstyle=wordwrap</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<id>UMLClass</id>
|
||||
<coordinates>
|
||||
<x>776</x>
|
||||
<y>688</y>
|
||||
<w>152</w>
|
||||
<h>40</h>
|
||||
</coordinates>
|
||||
<panel_attributes>NetworkClient
|
||||
--
|
||||
elementstyle=wordwrap</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>720</x>
|
||||
<y>448</y>
|
||||
<w>40</w>
|
||||
<h>160</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=>
|
||||
fg=red</panel_attributes>
|
||||
<additional_attributes>24;24;24;144</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<id>UMLClass</id>
|
||||
<coordinates>
|
||||
<x>664</x>
|
||||
<y>432</y>
|
||||
<w>152</w>
|
||||
<h>40</h>
|
||||
</coordinates>
|
||||
<panel_attributes>GameProtocols
|
||||
--
|
||||
elementstyle=wordwrap
|
||||
bg=green</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>592</x>
|
||||
<y>424</y>
|
||||
<w>88</w>
|
||||
<h>48</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=></panel_attributes>
|
||||
<additional_attributes>24;32;72;24</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<id>UMLClass</id>
|
||||
<coordinates>
|
||||
<x>464</x>
|
||||
<y>440</y>
|
||||
<w>152</w>
|
||||
<h>40</h>
|
||||
</coordinates>
|
||||
<panel_attributes>DanBiasServer
|
||||
--
|
||||
elementstyle=wordwrap
|
||||
bg=green</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<id>UMLClass</id>
|
||||
<coordinates>
|
||||
<x>880</x>
|
||||
<y>440</y>
|
||||
<w>152</w>
|
||||
<h>40</h>
|
||||
</coordinates>
|
||||
<panel_attributes>DanBiasGame
|
||||
--
|
||||
elementstyle=wordwrap
|
||||
bg=green</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>792</x>
|
||||
<y>424</y>
|
||||
<w>104</w>
|
||||
<h>48</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=></panel_attributes>
|
||||
<additional_attributes>88;32;24;24</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>608</x>
|
||||
<y>608</y>
|
||||
<w>152</w>
|
||||
<h>96</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=>
|
||||
fg=blue</panel_attributes>
|
||||
<additional_attributes>24;80;24;56;136;56;136;24</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>736</x>
|
||||
<y>608</y>
|
||||
<w>136</w>
|
||||
<h>96</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=>
|
||||
fg=blue</panel_attributes>
|
||||
<additional_attributes>120;80;120;56;24;56;24;24</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>688</x>
|
||||
<y>680</y>
|
||||
<w>104</w>
|
||||
<h>40</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=<
|
||||
fg=blue</panel_attributes>
|
||||
<additional_attributes>88;24;24;24</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>512</x>
|
||||
<y>456</y>
|
||||
<w>64</w>
|
||||
<h>264</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=>
|
||||
fg=red</panel_attributes>
|
||||
<additional_attributes>24;24;24;248;48;248</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>904</x>
|
||||
<y>456</y>
|
||||
<w>64</w>
|
||||
<h>272</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=>
|
||||
fg=red</panel_attributes>
|
||||
<additional_attributes>48;24;48;256;24;256</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>504</x>
|
||||
<y>456</y>
|
||||
<w>288</w>
|
||||
<h>304</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=>
|
||||
fg=red</panel_attributes>
|
||||
<additional_attributes>24;24;24;288;248;288;248;256;272;256</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Package</type>
|
||||
<coordinates>
|
||||
<x>544</x>
|
||||
<y>568</y>
|
||||
<w>400</w>
|
||||
<h>168</h>
|
||||
</coordinates>
|
||||
<panel_attributes>bg=orange
|
||||
NetworkAPI</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>720</x>
|
||||
<y>240</y>
|
||||
<w>40</w>
|
||||
<h>208</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=.
|
||||
fg=red</panel_attributes>
|
||||
<additional_attributes>24;24;24;192</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<id>UMLClass</id>
|
||||
<coordinates>
|
||||
<x>520</x>
|
||||
<y>168</y>
|
||||
<w>120</w>
|
||||
<h>56</h>
|
||||
</coordinates>
|
||||
<panel_attributes>ProtocolIdentificationID
|
||||
--
|
||||
/Collection of uniuqe/
|
||||
/protocol identifications/
|
||||
</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<id>UMLClass</id>
|
||||
<coordinates>
|
||||
<x>824</x>
|
||||
<y>176</y>
|
||||
<w>120</w>
|
||||
<h>48</h>
|
||||
</coordinates>
|
||||
<panel_attributes>GameProtocols
|
||||
--
|
||||
/Collects protocols/
|
||||
</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<id>UMLClass</id>
|
||||
<coordinates>
|
||||
<x>696</x>
|
||||
<y>136</y>
|
||||
<w>88</w>
|
||||
<h>24</h>
|
||||
</coordinates>
|
||||
<panel_attributes>ControlProtocols
|
||||
</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<id>UMLClass</id>
|
||||
<coordinates>
|
||||
<x>696</x>
|
||||
<y>168</y>
|
||||
<w>88</w>
|
||||
<h>24</h>
|
||||
</coordinates>
|
||||
<panel_attributes>LobbyProtocols
|
||||
</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<id>UMLClass</id>
|
||||
<coordinates>
|
||||
<x>696</x>
|
||||
<y>200</y>
|
||||
<w>88</w>
|
||||
<h>24</h>
|
||||
</coordinates>
|
||||
<panel_attributes>ObjectProtocols</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<id>UMLClass</id>
|
||||
<coordinates>
|
||||
<x>696</x>
|
||||
<y>232</y>
|
||||
<w>88</w>
|
||||
<h>24</h>
|
||||
</coordinates>
|
||||
<panel_attributes>PlayerProtocols
|
||||
</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>760</x>
|
||||
<y>184</y>
|
||||
<w>80</w>
|
||||
<h>72</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=></panel_attributes>
|
||||
<additional_attributes>64;24;48;24;48;56;24;56</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>760</x>
|
||||
<y>176</y>
|
||||
<w>80</w>
|
||||
<h>48</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=></panel_attributes>
|
||||
<additional_attributes>64;24;40;24;40;32;24;32</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>760</x>
|
||||
<y>160</y>
|
||||
<w>80</w>
|
||||
<h>48</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=></panel_attributes>
|
||||
<additional_attributes>64;32;40;32;40;24;24;24</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>760</x>
|
||||
<y>128</y>
|
||||
<w>80</w>
|
||||
<h>72</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=></panel_attributes>
|
||||
<additional_attributes>64;56;48;56;48;24;24;24</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>616</x>
|
||||
<y>184</y>
|
||||
<w>96</w>
|
||||
<h>72</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=></panel_attributes>
|
||||
<additional_attributes>80;56;56;56;56;24;24;24</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>616</x>
|
||||
<y>176</y>
|
||||
<w>96</w>
|
||||
<h>48</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=></panel_attributes>
|
||||
<additional_attributes>80;32;64;32;64;24;24;24</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>616</x>
|
||||
<y>160</y>
|
||||
<w>96</w>
|
||||
<h>48</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=></panel_attributes>
|
||||
<additional_attributes>80;24;64;24;64;32;24;32</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>616</x>
|
||||
<y>128</y>
|
||||
<w>96</w>
|
||||
<h>72</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=></panel_attributes>
|
||||
<additional_attributes>80;24;56;24;56;56;24;56</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Package</type>
|
||||
<coordinates>
|
||||
<x>512</x>
|
||||
<y>112</y>
|
||||
<w>440</w>
|
||||
<h>152</h>
|
||||
</coordinates>
|
||||
<panel_attributes>bg=orange
|
||||
GameProtocols</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<id>UMLClass</id>
|
||||
<coordinates>
|
||||
<x>744</x>
|
||||
<y>312</y>
|
||||
<w>184</w>
|
||||
<h>72</h>
|
||||
</coordinates>
|
||||
<panel_attributes>Protocols is created in a seperate module because both server and client needs to share the same protocols and the same protocol identifications.
|
||||
elementstyle=wordwrap</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
</diagram>
|
|
@ -1,12 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<diagram program="umlet" version="12.1">
|
||||
<diagram program="umlet" version="12.2">
|
||||
<zoom_level>12</zoom_level>
|
||||
<element>
|
||||
<type>com.umlet.element.Class</type>
|
||||
<coordinates>
|
||||
<x>540</x>
|
||||
<y>456</y>
|
||||
<w>132</w>
|
||||
<y>468</y>
|
||||
<w>336</w>
|
||||
<h>36</h>
|
||||
</coordinates>
|
||||
<panel_attributes>OysterThread</panel_attributes>
|
||||
|
@ -16,9 +16,9 @@
|
|||
<type>com.umlet.element.Class</type>
|
||||
<coordinates>
|
||||
<x>372</x>
|
||||
<y>408</y>
|
||||
<y>396</y>
|
||||
<w>120</w>
|
||||
<h>36</h>
|
||||
<h>48</h>
|
||||
</coordinates>
|
||||
<panel_attributes>/Some class/</panel_attributes>
|
||||
<additional_attributes/>
|
||||
|
@ -29,11 +29,11 @@
|
|||
<x>336</x>
|
||||
<y>300</y>
|
||||
<w>228</w>
|
||||
<h>132</h>
|
||||
<h>120</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=>>>>>-
|
||||
<<implements>></panel_attributes>
|
||||
<additional_attributes>96;108;96;60;204;60</additional_attributes>
|
||||
<additional_attributes>96;96;96;60;204;60</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
|
@ -41,52 +41,30 @@
|
|||
<x>396</x>
|
||||
<y>408</y>
|
||||
<w>168</w>
|
||||
<h>96</h>
|
||||
<h>108</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=<<<<-
|
||||
Creates>></panel_attributes>
|
||||
<additional_attributes>36;36;36;72;132;72;144;72</additional_attributes>
|
||||
<additional_attributes>36;36;36;84;132;84;144;84</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>564</x>
|
||||
<y>372</y>
|
||||
<x>660</x>
|
||||
<y>384</y>
|
||||
<w>60</w>
|
||||
<h>108</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=<<<-</panel_attributes>
|
||||
<additional_attributes>36;84;36;36</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Class</type>
|
||||
<coordinates>
|
||||
<x>540</x>
|
||||
<y>540</y>
|
||||
<w>132</w>
|
||||
<h>36</h>
|
||||
</coordinates>
|
||||
<panel_attributes>OysterMutex</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>564</x>
|
||||
<y>456</y>
|
||||
<w>60</w>
|
||||
<h>108</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=<<<<-</panel_attributes>
|
||||
<additional_attributes>36;36;36;84</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<id>UMLClass</id>
|
||||
<coordinates>
|
||||
<x>540</x>
|
||||
<y>312</y>
|
||||
<w>336</w>
|
||||
<h>96</h>
|
||||
<h>108</h>
|
||||
</coordinates>
|
||||
<panel_attributes>/<<interface>>/
|
||||
IThreadObject
|
||||
|
@ -123,16 +101,4 @@ bg=red</panel_attributes>
|
|||
<panel_attributes>lt=-</panel_attributes>
|
||||
<additional_attributes>36;36;36;108</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<type>com.umlet.element.Relation</type>
|
||||
<coordinates>
|
||||
<x>336</x>
|
||||
<y>408</y>
|
||||
<w>228</w>
|
||||
<h>168</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=>>.
|
||||
uses</panel_attributes>
|
||||
<additional_attributes>60;36;60;144;204;144</additional_attributes>
|
||||
</element>
|
||||
</diagram>
|
||||
|
|
|
@ -3,6 +3,5 @@
|
|||
|
||||
BOOL WINAPI DllMain( _In_ HINSTANCE hinstDLL, _In_ DWORD fdwReason, _In_ LPVOID lpvReserved )
|
||||
{
|
||||
//MessageBox(0, L"DanBiasGame Loaded", 0, 0);
|
||||
return TRUE;
|
||||
}
|
|
@ -5,7 +5,7 @@
|
|||
#include "GameClientState/GameClientState.h"
|
||||
#include "GameClientState\GameState.h"
|
||||
#include "GameClientState\LobbyState.h"
|
||||
#include <GameProtocols.h>
|
||||
#include <Protocols.h>
|
||||
#include "NetworkClient.h"
|
||||
|
||||
#include "../WindowManager/WindowShell.h"
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include "DllInterfaces/GFXAPI.h"
|
||||
#include "C_obj/C_Player.h"
|
||||
#include "C_obj/C_DynamicObj.h"
|
||||
#include <GameProtocols.h>
|
||||
#include <Protocols.h>
|
||||
#include "NetworkClient.h"
|
||||
|
||||
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
/////////////////////////////////////////
|
||||
// Created by [Dennis Andersen] [2013] //
|
||||
/////////////////////////////////////////
|
||||
#ifndef DANBIASGAME_DANBIASGAME_H
|
||||
#define DANBIASGAME_DANBIASGAME_H
|
||||
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
/////////////////////////////////////////
|
||||
// Created by [Dennis Andersen] [2013] //
|
||||
/////////////////////////////////////////
|
||||
#ifndef DANBIASSERVER_ADMIN_INTERFACE_H
|
||||
#define DANBIASSERVER_ADMIN_INTERFACE_H
|
||||
|
||||
|
|
|
@ -179,10 +179,13 @@
|
|||
<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.cpp" />
|
||||
<ClCompile Include="GameSession\GameSession_Logic.cpp" />
|
||||
<ClCompile Include="LobbySessions\MainLobby.cpp" />
|
||||
<ClCompile Include="LobbySessions\NetworkSession.cpp" />
|
||||
</ItemGroup>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/////////////////////////////////////////////////////////////////////
|
||||
// Created by [Dennis Andersen] [2013]
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////
|
||||
// Created by [Dennis Andersen] [2013] //
|
||||
/////////////////////////////////////////
|
||||
#ifndef DANBIAS_SERVER_DANBIAS_SERVER_H
|
||||
#define DANBIAS_SERVER_DANBIAS_SERVER_H
|
||||
|
||||
|
|
|
@ -22,10 +22,12 @@ namespace DanBias
|
|||
{
|
||||
using namespace Oyster::Network;
|
||||
|
||||
GameServer* GameServer::instance = 0;
|
||||
|
||||
void GameServer::NetworkCallback(NetworkClient* client)
|
||||
{
|
||||
static GameSession *myTest = 0;
|
||||
static bool myTest = false;
|
||||
static int sessionId = -1;
|
||||
printf("Client with ID [%i] connected.\n", client->GetID());
|
||||
|
||||
if(!myTest)
|
||||
|
@ -36,10 +38,9 @@ namespace DanBias
|
|||
desc.mapName = L"test";
|
||||
desc.clients.Push(c);
|
||||
desc.exitDestionation = this->mainLobby;
|
||||
int sessionId = 0;
|
||||
if((sessionId = GameSessionManager::AddSession(desc, true)) == 0)
|
||||
printf("Failed to create a game session");
|
||||
|
||||
printf("Failed to create a game session\n");
|
||||
myTest = true;
|
||||
//myTest = new GameSession();
|
||||
//
|
||||
//DanBias::GameSession::GameSessionDescription desc;
|
||||
|
@ -52,7 +53,7 @@ namespace DanBias
|
|||
else
|
||||
{
|
||||
Utility::DynamicMemory::SmartPointer<LobbyClient> c = new LobbyClient(client);
|
||||
myTest->Join(c);
|
||||
GameSessionManager::JoinSession(sessionId, c);
|
||||
}
|
||||
|
||||
|
||||
|
@ -68,7 +69,7 @@ namespace DanBias
|
|||
, maxClients(0)
|
||||
, mainLobby(0)
|
||||
, server(0)
|
||||
{ }
|
||||
{ this->instance = this; }
|
||||
GameServer::~GameServer()
|
||||
{
|
||||
|
||||
|
@ -89,7 +90,6 @@ namespace DanBias
|
|||
|
||||
if(!this->server->Init(serverDesc)) return DanBiasServerReturn_Error;
|
||||
if(!WindowShell::CreateConsoleWindow()) return DanBiasServerReturn_Error;
|
||||
//if(!WindowShell::CreateWin(WindowShell::WINDOW_INIT_DESC())) return DanBiasServerReturn_Error;
|
||||
|
||||
this->initiated = true;
|
||||
return DanBiasServerReturn_Sucess;
|
||||
|
@ -108,10 +108,9 @@ namespace DanBias
|
|||
{
|
||||
if(!WindowShell::Frame()) break;
|
||||
|
||||
|
||||
this->mainLobby->Frame();
|
||||
|
||||
if(GetAsyncKeyState(0x51))
|
||||
if(GetAsyncKeyState(0x51)) //Q for exit
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -119,6 +118,8 @@ namespace DanBias
|
|||
}
|
||||
DanBiasServerReturn GameServer::Release()
|
||||
{
|
||||
GameSessionManager::CloseSession();
|
||||
this->mainLobby->Release();
|
||||
delete this->mainLobby;
|
||||
this->server->Shutdown();
|
||||
delete this->server;
|
||||
|
@ -126,6 +127,11 @@ namespace DanBias
|
|||
return DanBiasServerReturn_Sucess;
|
||||
}
|
||||
|
||||
NetworkSession* GameServer::MainLobbyInstance()
|
||||
{
|
||||
return GameServer::instance->mainLobby;
|
||||
}
|
||||
|
||||
bool GameServer::LoadIniFile(InitData& ini)
|
||||
{
|
||||
std::ifstream in;
|
||||
|
|
|
@ -21,6 +21,8 @@ namespace DanBias
|
|||
DanBiasServerReturn Run();
|
||||
DanBiasServerReturn Release();
|
||||
|
||||
static NetworkSession* MainLobbyInstance();
|
||||
|
||||
private:
|
||||
//static void ClientConnectCallbackFunction(Oyster::Network::NetworkClient& connectedClient);
|
||||
void NetworkCallback(Oyster::Network::NetworkClient* client) override;
|
||||
|
@ -31,6 +33,7 @@ namespace DanBias
|
|||
int maxClients;
|
||||
MainLobby *mainLobby;
|
||||
Oyster::Network::NetworkServer *server;
|
||||
static GameServer* instance;
|
||||
|
||||
private:
|
||||
struct InitData
|
||||
|
|
|
@ -4,16 +4,21 @@
|
|||
|
||||
#include "GameClient.h"
|
||||
#include "..\LobbySessions\NetworkSession.h"
|
||||
#include <GameProtocols.h>
|
||||
#include <Game.h>
|
||||
#include <Protocols.h>
|
||||
|
||||
using namespace Utility::DynamicMemory;
|
||||
using namespace DanBias;
|
||||
using namespace GameLogic;
|
||||
|
||||
GameClient::GameClient(SmartPointer<LobbyClient> client, Oyster::Callback::OysterCallback<void, NetworkSession::NetEvent> value)
|
||||
static int gameClientIDCount = 1;
|
||||
|
||||
GameClient::GameClient(SmartPointer<LobbyClient> client, Game::PlayerData player, Oyster::Callback::OysterCallback<void, NetworkSession::NetEvent> value)
|
||||
{
|
||||
this->callbackValue = value;
|
||||
this->client = client;
|
||||
this->player = new GameLogic::Player();
|
||||
this->id = gameClientIDCount++;
|
||||
this->player = player;
|
||||
Oyster::Callback::OysterCallback<void, NetworkSession::NetEvent> c;
|
||||
c.callbackType = Oyster::Callback::CallbackType_Object;
|
||||
c.value = this;
|
||||
|
@ -22,8 +27,10 @@ GameClient::GameClient(SmartPointer<LobbyClient> client, Oyster::Callback::Oyste
|
|||
}
|
||||
GameClient::~GameClient()
|
||||
{
|
||||
this->client->Disconnect();
|
||||
this->player.Release();
|
||||
if(this->client) this->client->Disconnect();
|
||||
this->player.playerID = 0;
|
||||
this->player.teamID = 0;
|
||||
this->id = -1;
|
||||
}
|
||||
|
||||
void GameClient::SetCallback(Oyster::Callback::OysterCallback<void, NetworkSession::NetEvent> value)
|
||||
|
@ -31,15 +38,31 @@ void GameClient::SetCallback(Oyster::Callback::OysterCallback<void, NetworkSessi
|
|||
this->callbackValue = value;
|
||||
}
|
||||
|
||||
GameLogic::Player* GameClient::GetPlayer()
|
||||
GameLogic::Game::PlayerData* GameClient::GetPlayer()
|
||||
{
|
||||
return this->player.Get();
|
||||
return &this->player;
|
||||
}
|
||||
LobbyClient* GameClient::GetClient()
|
||||
GameLogic::Game::PlayerData GameClient::ReleasePlayer()
|
||||
{
|
||||
GameLogic::Game::PlayerData temp = this->player;
|
||||
this->player.playerID = 0;
|
||||
this->player.teamID = 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;
|
||||
|
|
|
@ -6,28 +6,34 @@
|
|||
|
||||
#include "..\LobbySessions\LobbyClient.h"
|
||||
#include <PostBox\PostBox.h>
|
||||
#include <Player.h>
|
||||
#include <Game.h>
|
||||
|
||||
namespace DanBias
|
||||
{
|
||||
class GameClient: Oyster::Callback::CallbackObject<void, NetworkSession::NetEvent>
|
||||
{
|
||||
public:
|
||||
GameClient(Utility::DynamicMemory::SmartPointer<LobbyClient> client, Oyster::Callback::OysterCallback<void, NetworkSession::NetEvent> value);
|
||||
GameClient(Utility::DynamicMemory::SmartPointer<LobbyClient> client, GameLogic::Game::PlayerData player, Oyster::Callback::OysterCallback<void, NetworkSession::NetEvent> value);
|
||||
virtual~GameClient();
|
||||
|
||||
void SetCallback(Oyster::Callback::OysterCallback<void, NetworkSession::NetEvent> value);
|
||||
|
||||
GameLogic::Player* GetPlayer();
|
||||
LobbyClient* GetClient();
|
||||
//GameLogic::Player* GetPlayer();
|
||||
GameLogic::Game::PlayerData* GetPlayer();
|
||||
GameLogic::Game::PlayerData ReleasePlayer();
|
||||
|
||||
LobbyClient* GetClient() const;
|
||||
Utility::DynamicMemory::SmartPointer<LobbyClient> ReleaseClient();
|
||||
int GetID() const;
|
||||
|
||||
private:
|
||||
Utility::DynamicMemory::SmartPointer<GameLogic::Player> player;
|
||||
//Utility::DynamicMemory::SmartPointer<GameLogic::Player> player;
|
||||
GameLogic::Game::PlayerData player;
|
||||
Utility::DynamicMemory::SmartPointer<LobbyClient> client;
|
||||
Oyster::Callback::OysterCallback<void, NetworkSession::NetEvent> callbackValue;
|
||||
|
||||
int id;
|
||||
void ObjectCallback(NetworkSession::NetEvent) override;
|
||||
|
||||
|
||||
private:
|
||||
friend class AdminInterface;
|
||||
};
|
||||
|
|
|
@ -1,332 +0,0 @@
|
|||
/////////////////////////////////////////////////////////////////////
|
||||
// Created by [Dennis Andersen] [2013]
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
#include "GameSession.h"
|
||||
#include "GameClient.h"
|
||||
|
||||
#include <GameProtocols.h>
|
||||
#include <PostBox\PostBox.h>
|
||||
#include <GameLogicStates.h>
|
||||
|
||||
#include <Windows.h>
|
||||
|
||||
|
||||
using namespace Utility::DynamicMemory;
|
||||
using namespace Oyster;
|
||||
using namespace Oyster::Network;
|
||||
using namespace Oyster::Thread;
|
||||
using namespace GameLogic;
|
||||
|
||||
namespace DanBias
|
||||
{
|
||||
void InsertObject(DynamicArray<SmartPointer<GameClient>>& clients, SmartPointer<GameClient> obj)
|
||||
{
|
||||
for (unsigned int i = 0; i < clients.Size(); i++)
|
||||
{
|
||||
if(!clients[i])
|
||||
{
|
||||
clients[i] = obj;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
void RemoveObject(DynamicArray<SmartPointer<GameClient>>& clients, DanBias::GameClient* obj)
|
||||
{
|
||||
for (unsigned int i = 0; i < clients.Size(); i++)
|
||||
{
|
||||
if(clients[i] && clients[i]->GetClient()->GetID() == obj->GetClient()->GetID())
|
||||
{
|
||||
clients[i] = 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GameSession::GameSession()
|
||||
{
|
||||
this->owner = 0;
|
||||
this->box = 0;
|
||||
this->isCreated = false;
|
||||
this->isRunning = false;
|
||||
}
|
||||
GameSession::~GameSession()
|
||||
{
|
||||
delete this->box;
|
||||
this->box = 0;
|
||||
this->owner = 0;
|
||||
}
|
||||
|
||||
bool GameSession::Create(GameDescription& desc)
|
||||
{
|
||||
if(desc.clients.Size() == 0) return false;
|
||||
if(!desc.owner) return false;
|
||||
if(!desc.mapName.size()) return false;
|
||||
if(this->isCreated) return false;
|
||||
|
||||
this->clients.Resize(desc.clients.Size());
|
||||
|
||||
this->box = new PostBox<NetworkSession::NetEvent>();
|
||||
this->owner = desc.owner;
|
||||
|
||||
Oyster::Callback::OysterCallback<void, NetworkSession::NetEvent> c;
|
||||
c.value.callbackPostBox = this->box;
|
||||
c.callbackType = Oyster::Callback::CallbackType_PostBox;
|
||||
|
||||
for (unsigned int i = 0; i < desc.clients.Size(); i++)
|
||||
{
|
||||
this->clients[i] = new GameClient(desc.clients[i], c);
|
||||
}
|
||||
|
||||
this->isCreated = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
void GameSession::Run()
|
||||
{
|
||||
if(this->isRunning) return;
|
||||
if(this->clients.Size() > 0)
|
||||
{
|
||||
if(this->worker.Create(this, true, true) != OYSTER_THREAD_ERROR_SUCCESS) return;
|
||||
this->worker.SetPriority(OYSTER_THREAD_PRIORITY_2);
|
||||
this->isRunning = true;
|
||||
}
|
||||
}
|
||||
|
||||
bool GameSession::Join(Utility::DynamicMemory::SmartPointer<LobbyClient> client)
|
||||
{
|
||||
if(!this->isCreated) return false;
|
||||
|
||||
Oyster::Callback::OysterCallback<void, DanBias::NetworkSession::NetEvent> c;
|
||||
c.value.callbackPostBox = this->box;
|
||||
c.callbackType = Oyster::Callback::CallbackType_PostBox;
|
||||
|
||||
SmartPointer<GameClient> obj = new GameClient(client, c);
|
||||
InsertObject(this->clients, obj);
|
||||
|
||||
return true;
|
||||
}
|
||||
void GameSession::CloseSession(bool dissconnectClients)
|
||||
{
|
||||
this->worker.Stop(false);
|
||||
//NetworkSession::CloseSession(dissconnectClients);
|
||||
this->isCreated = false;
|
||||
this->isRunning = false;
|
||||
}
|
||||
|
||||
////private: //overriden Threading functions
|
||||
bool GameSession::DoWork ( )
|
||||
{
|
||||
this->Frame();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifndef ERIK
|
||||
////private:
|
||||
void GameSession::Frame()
|
||||
{
|
||||
this->ParseEvents();
|
||||
|
||||
if(GetAsyncKeyState(VK_UP))
|
||||
{
|
||||
Protocol_General_Status p(Protocol_General_Status::States_ready);
|
||||
Send(p.GetProtocol());
|
||||
Sleep(100);
|
||||
}
|
||||
if(GetAsyncKeyState(VK_DOWN))
|
||||
{
|
||||
Oyster::Math::Float4x4 world = Oyster::Math::Matrix::identity;
|
||||
Protocol_CreateObject p(world, 2, "../Content/crate");
|
||||
Send(p.GetProtocol());
|
||||
Sleep(100);
|
||||
}
|
||||
}
|
||||
void GameSession::ParseEvents()
|
||||
{
|
||||
if( !this->box->IsEmpty() )
|
||||
{
|
||||
NetworkSession::NetEvent &e = this->box->Fetch();
|
||||
|
||||
if(e.protocol[0].type != Oyster::Network::NetAttributeType_Short) return;
|
||||
|
||||
if( ProtocolIsGameplay(e.protocol[protocol_INDEX_ID].value.netShort) )
|
||||
ParseGameplayEvent(e.protocol, e.gameClient);
|
||||
|
||||
if( ProtocolIsGeneral(e.protocol[protocol_INDEX_ID].value.netShort) )
|
||||
ParseGeneralEvent(e.protocol, e.gameClient);
|
||||
}
|
||||
}
|
||||
|
||||
void GameSession::ParseGameplayEvent(Oyster::Network::CustomNetProtocol& p, DanBias::GameClient* c)
|
||||
{
|
||||
switch (p[protocol_INDEX_ID].value.netShort)
|
||||
{
|
||||
case protocol_Gameplay_PlayerNavigation:
|
||||
{
|
||||
|
||||
Oyster::Math::Float4x4 world = Oyster::Math::Matrix::identity;
|
||||
if(p[1].value.netBool) //bool bForward;
|
||||
world.v[3].y = 2;
|
||||
//c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_FORWARD);
|
||||
if(p[2].value.netBool) //bool bBackward;
|
||||
world.v[3].y = -2;
|
||||
//c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_BACKWARD);
|
||||
if(p[5].value.netBool) //bool bStrafeRight;
|
||||
world.v[3].x = -2;
|
||||
//c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_RIGHT);
|
||||
if(p[6].value.netBool) //bool bStrafeLeft;
|
||||
world.v[3].x = 2;
|
||||
//c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_LEFT);
|
||||
|
||||
Protocol_ObjectPosition res(world, 0);
|
||||
Send(res.GetProtocol());
|
||||
|
||||
|
||||
}
|
||||
break;
|
||||
case protocol_Gameplay_PlayerMouseMovement:
|
||||
|
||||
break;
|
||||
case protocol_Gameplay_PlayerPosition:
|
||||
|
||||
break;
|
||||
case protocol_Gameplay_CreateObject:
|
||||
|
||||
break;
|
||||
case protocol_Gameplay_ObjectPosition:
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
void GameSession::ParseGeneralEvent(Oyster::Network::CustomNetProtocol& p, DanBias::GameClient* c)
|
||||
{
|
||||
switch (p[protocol_INDEX_ID].value.netShort)
|
||||
{
|
||||
case protocol_General_Status:
|
||||
switch (p[1].value.netInt)
|
||||
{
|
||||
case GameLogic::Protocol_General_Status::States_bussy:
|
||||
|
||||
break;
|
||||
|
||||
case GameLogic::Protocol_General_Status::States_disconected:
|
||||
printf("Client with ID [%i] dissconnected", c->GetClient()->GetID());
|
||||
RemoveObject(this->clients, c);
|
||||
break;
|
||||
|
||||
case GameLogic::Protocol_General_Status::States_idle:
|
||||
break;
|
||||
|
||||
case GameLogic::Protocol_General_Status::States_ready:
|
||||
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case protocol_General_Text:
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
void GameSession::Send(Oyster::Network::CustomNetProtocol* p)
|
||||
{
|
||||
for (unsigned int i = 0; i < this->clients.Size(); i++)
|
||||
{
|
||||
if(this->clients[i] && this->clients[i]->GetClient())
|
||||
this->clients[i]->GetClient()->Send(p);
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
#include "DynamicObject.h"
|
||||
//#include "CollisionManager.h"
|
||||
//#include "GameLogicStates.h"
|
||||
//#include <GameProtocols.h>
|
||||
|
||||
/*
|
||||
using namespace GameLogic;
|
||||
//VARIABLES GOES HERE
|
||||
DynamicObject* objectBox;
|
||||
|
||||
bool GameSession::Init(GameSessionDescription& desc)
|
||||
{
|
||||
if(desc.clients.Size() == 0) return false;
|
||||
this->box = new PostBox<NetEvent>();
|
||||
this->owner = desc.owner;
|
||||
for (unsigned int i = 0; i < desc.clients.Size(); i++)
|
||||
{
|
||||
desc.clients[i]->SetPostbox(this->box);
|
||||
this->clients.Push(desc.clients[i]);
|
||||
}
|
||||
|
||||
CollisionManager::BoxCollision(0,0);
|
||||
|
||||
objectBox = new DynamicObject(CollisionManager::BoxCollision, OBJECT_TYPE::OBJECT_TYPE_BOX);
|
||||
|
||||
Protocol_CreateObject objectCreation;
|
||||
objectCreation.object_ID = objectBox->GetID();
|
||||
objectCreation.path = "crate";
|
||||
Oyster::Math::Float4x4 worldMat = objectBox->GetRigidBody()->GetOrientation();
|
||||
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
objectCreation.worldMatrix[i] = worldMat[i];
|
||||
}
|
||||
|
||||
for (int i = 0; i < clients.Size(); i++)
|
||||
{
|
||||
clients[i]->NetClient_Object()->Send(objectCreation);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
void GameSession::Frame()
|
||||
{
|
||||
}
|
||||
void GameSession::ParseEvents()
|
||||
{
|
||||
if(this->box && !this->box->IsEmpty())
|
||||
{
|
||||
NetEvent &e = this->box->Fetch();
|
||||
|
||||
if(e.protocol[0].type != Oyster::Network::NetAttributeType_Short) return;
|
||||
|
||||
ParseProtocol(e.protocol, *e.reciever);
|
||||
}
|
||||
}
|
||||
void GameSession::ParseProtocol(Oyster::Network::CustomNetProtocol& p, DanBias::ClientObject& c)
|
||||
{
|
||||
switch (p[0].value.netShort)
|
||||
{
|
||||
case protocol_Gamplay_PlayerNavigation:
|
||||
{
|
||||
if(p[1].value.netBool) //bool bForward;
|
||||
c.Logic_Object()->Move(GameLogic::PLAYER_MOVEMENT_FORWARD);
|
||||
if(p[2].value.netBool) //bool bBackward;
|
||||
c.Logic_Object()->Move(GameLogic::PLAYER_MOVEMENT_BACKWARD);
|
||||
if(p[5].value.netBool) //bool bStrafeRight;
|
||||
c.Logic_Object()->Move(GameLogic::PLAYER_MOVEMENT_RIGHT);
|
||||
if(p[6].value.netBool) //bool bStrafeLeft;
|
||||
c.Logic_Object()->Move(GameLogic::PLAYER_MOVEMENT_LEFT);
|
||||
}
|
||||
break;
|
||||
case protocol_Gamplay_PlayerMouseMovement:
|
||||
|
||||
break;
|
||||
case protocol_Gamplay_PlayerPosition:
|
||||
|
||||
break;
|
||||
case protocol_Gamplay_CreateObject:
|
||||
|
||||
break;
|
||||
case protocol_Gamplay_ObjectPosition:
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
#endif
|
||||
|
||||
}//End namespace DanBias
|
||||
|
|
@ -4,12 +4,14 @@
|
|||
#ifndef DANBIASSERVER_GAME_SESSION_H
|
||||
#define DANBIASSERVER_GAME_SESSION_H
|
||||
|
||||
//warning C4150: deletion of pointer to incomplete type, no destructor called
|
||||
//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 <WinTimer.h>
|
||||
#include <PostBox\IPostBox.h>
|
||||
#include <Thread\OysterThread.h>
|
||||
#include <Game.h>
|
||||
|
||||
namespace DanBias
|
||||
{
|
||||
|
@ -18,6 +20,9 @@ namespace DanBias
|
|||
class GameSession : public Oyster::Thread::IThreadObject, public INetworkSession
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* A container to use when initiating a new session
|
||||
*/
|
||||
struct GameDescription
|
||||
{
|
||||
std::wstring mapName;
|
||||
|
@ -41,31 +46,44 @@ namespace DanBias
|
|||
bool Join(Utility::DynamicMemory::SmartPointer<LobbyClient> client);
|
||||
|
||||
/**
|
||||
*
|
||||
* Closes the game session
|
||||
* @param disconnectClients If set to true clients is dissconnected from the server, if false the clients is sent to the given owner of the session.
|
||||
*/
|
||||
void CloseSession(bool dissconnectClients = false);
|
||||
|
||||
void CloseSession(bool disconnectClients = false);
|
||||
|
||||
inline bool IsCreated() const { return this->isCreated; }
|
||||
inline bool IsRunning() const { return this->isRunning; }
|
||||
|
||||
|
||||
//Private member functions
|
||||
private:
|
||||
void Frame();
|
||||
//Handles all events recieved
|
||||
void ParseEvents();
|
||||
//Handles all gameplay events
|
||||
void ParseGameplayEvent(Oyster::Network::CustomNetProtocol& p, DanBias::GameClient* c);
|
||||
//Handles all general events
|
||||
void ParseGeneralEvent(Oyster::Network::CustomNetProtocol& p, DanBias::GameClient* c);
|
||||
|
||||
//Adds a client to the client list
|
||||
void AddClient(Utility::DynamicMemory::SmartPointer<GameClient> obj);
|
||||
//Removes a client from the client list
|
||||
void RemoveClient(DanBias::GameClient* obj);
|
||||
//Sends a protocol ta all clients in session
|
||||
void Send(Oyster::Network::CustomNetProtocol* p);
|
||||
|
||||
private: //overriden Threading functions
|
||||
//Frame function, derived from IThreadObject
|
||||
bool DoWork ( ) override;
|
||||
//Sends a client to the owner, if obj is NULL then all clients is sent
|
||||
void SendToOwner(DanBias::GameClient* obj);
|
||||
//Do a cleanup on all the private data
|
||||
void Clean();
|
||||
|
||||
//Private member variables
|
||||
private:
|
||||
|
||||
Utility::DynamicMemory::DynamicArray<Utility::DynamicMemory::SmartPointer<GameClient>> clients;
|
||||
NetworkSession* owner;
|
||||
Oyster::IPostBox<DanBias::NetworkSession::NetEvent> *box;
|
||||
Oyster::Thread::OysterThread worker;
|
||||
GameLogic::Game gameInstance;
|
||||
NetworkSession* owner;
|
||||
Utility::WinTimer timer;
|
||||
bool isCreated;
|
||||
bool isRunning;
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ bool GameSessionManager::StartSession(int session)
|
|||
bool GameSessionManager::JoinSession(int session, Utility::DynamicMemory::SmartPointer<LobbyClient> client)
|
||||
{
|
||||
int i = -1;
|
||||
if((i = gameSessionData.Existst(session)) != -1) return false;
|
||||
if((i = gameSessionData.Existst(session)) == -1) return false;
|
||||
|
||||
gameSessionData.sessions[i]->Join(client);
|
||||
|
||||
|
@ -97,6 +97,13 @@ void GameSessionManager::GetSessionInfo(int session, GameSessionInfo& data)
|
|||
//data.numberOfPlayers = gameSessionData.sessions[i]->
|
||||
}
|
||||
|
||||
void GameSessionManager::CloseSession()
|
||||
{
|
||||
for (unsigned int i = 0; i < gameSessionData.sessions.Size(); i++)
|
||||
{
|
||||
gameSessionData.sessions[i]->CloseSession();
|
||||
}
|
||||
}
|
||||
void GameSessionManager::CloseSession(int session)
|
||||
{
|
||||
int i = -1;
|
||||
|
|
|
@ -64,6 +64,11 @@ namespace DanBias
|
|||
*/
|
||||
static void CloseSession(int session);
|
||||
|
||||
/**
|
||||
* Close all sessions.
|
||||
*/
|
||||
static void CloseSession();
|
||||
|
||||
/**
|
||||
* Get total sessions running
|
||||
* @return Returns the total sessions curently running.
|
||||
|
|
|
@ -0,0 +1,114 @@
|
|||
/////////////////////////////////////////////////////////////////////
|
||||
// Created by [Dennis Andersen] [2013]
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
#include "GameSession.h"
|
||||
#include "GameClient.h"
|
||||
|
||||
#include <Protocols.h>
|
||||
#include <PostBox\PostBox.h>
|
||||
#include <GameLogicStates.h>
|
||||
#include <OysterMath.h>
|
||||
|
||||
#include <Windows.h>
|
||||
|
||||
|
||||
using namespace Utility::DynamicMemory;
|
||||
using namespace Oyster;
|
||||
using namespace Oyster::Network;
|
||||
using namespace Oyster::Thread;
|
||||
using namespace GameLogic;
|
||||
|
||||
namespace DanBias
|
||||
{
|
||||
void GameSession::ParseEvents()
|
||||
{
|
||||
if( !this->box->IsEmpty() )
|
||||
{
|
||||
NetworkSession::NetEvent &e = this->box->Fetch();
|
||||
|
||||
if(e.protocol[0].type != Oyster::Network::NetAttributeType_Short) return;
|
||||
|
||||
if( ProtocolIsGameplay(e.protocol[protocol_INDEX_ID].value.netShort) )
|
||||
ParseGameplayEvent(e.protocol, e.gameClient);
|
||||
|
||||
if( ProtocolIsGeneral(e.protocol[protocol_INDEX_ID].value.netShort) )
|
||||
ParseGeneralEvent(e.protocol, e.gameClient);
|
||||
}
|
||||
}
|
||||
|
||||
void GameSession::ParseGameplayEvent(Oyster::Network::CustomNetProtocol& p, DanBias::GameClient* c)
|
||||
{
|
||||
switch (p[protocol_INDEX_ID].value.netShort)
|
||||
{
|
||||
case protocol_Gameplay_PlayerNavigation:
|
||||
{
|
||||
|
||||
Oyster::Math::Float4x4 world = Oyster::Math::Matrix::identity;
|
||||
if(p[1].value.netBool) //bool bForward;
|
||||
world.v[3].x = 2;
|
||||
//c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_FORWARD);
|
||||
if(p[2].value.netBool) //bool bBackward;
|
||||
world.v[3].x = -2;
|
||||
//c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_BACKWARD);
|
||||
if(p[5].value.netBool) //bool bStrafeRight;
|
||||
world.v[3].y = 2;
|
||||
//c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_RIGHT);
|
||||
if(p[6].value.netBool) //bool bStrafeLeft;
|
||||
world.v[3].y = -2;
|
||||
//c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_LEFT);
|
||||
|
||||
Protocol_ObjectPosition res(world, 0);
|
||||
Send(res.GetProtocol());
|
||||
|
||||
|
||||
}
|
||||
break;
|
||||
case protocol_Gameplay_PlayerMouseMovement:
|
||||
|
||||
break;
|
||||
case protocol_Gameplay_PlayerPosition:
|
||||
|
||||
break;
|
||||
case protocol_Gameplay_CreateObject:
|
||||
|
||||
break;
|
||||
case protocol_Gameplay_ObjectPosition:
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void GameSession::ParseGeneralEvent(Oyster::Network::CustomNetProtocol& p, DanBias::GameClient* c)
|
||||
{
|
||||
switch (p[protocol_INDEX_ID].value.netShort)
|
||||
{
|
||||
case protocol_General_Status:
|
||||
switch (p[1].value.netInt)
|
||||
{
|
||||
case GameLogic::Protocol_General_Status::States_bussy:
|
||||
|
||||
break;
|
||||
|
||||
case GameLogic::Protocol_General_Status::States_disconected:
|
||||
printf("Client with ID [%i] dissconnected\n", c->GetClient()->GetID());
|
||||
this->RemoveClient(c);
|
||||
break;
|
||||
|
||||
case GameLogic::Protocol_General_Status::States_idle:
|
||||
|
||||
break;
|
||||
|
||||
case GameLogic::Protocol_General_Status::States_ready:
|
||||
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case protocol_General_Text:
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}//End namespace DanBias
|
||||
|
|
@ -0,0 +1,170 @@
|
|||
/////////////////////////////////////////////////////////////////////
|
||||
// Created by [Dennis Andersen] [2013]
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
#include "GameSession.h"
|
||||
#include "GameClient.h"
|
||||
#include "..\GameServer.h"
|
||||
#include <Protocols.h>
|
||||
#include <PostBox\PostBox.h>
|
||||
#include <GameLogicStates.h>
|
||||
|
||||
#include <Windows.h>
|
||||
|
||||
|
||||
using namespace Utility::DynamicMemory;
|
||||
using namespace Oyster;
|
||||
using namespace Oyster::Network;
|
||||
using namespace Oyster::Thread;
|
||||
using namespace GameLogic;
|
||||
|
||||
namespace DanBias
|
||||
{
|
||||
GameSession::GameSession()
|
||||
{
|
||||
this->owner = 0;
|
||||
this->box = 0;
|
||||
this->isCreated = false;
|
||||
this->isRunning = false;
|
||||
}
|
||||
|
||||
GameSession::~GameSession()
|
||||
{
|
||||
delete this->box;
|
||||
this->box = 0;
|
||||
this->owner = 0;
|
||||
}
|
||||
|
||||
bool GameSession::Create(GameDescription& desc)
|
||||
{
|
||||
if(desc.clients.Size() == 0) return false;
|
||||
if(!desc.owner) return false;
|
||||
if(!desc.mapName.size()) return false;
|
||||
if(this->isCreated) return false;
|
||||
|
||||
this->clients.Resize(desc.clients.Size());
|
||||
|
||||
this->box = new PostBox<NetworkSession::NetEvent>();
|
||||
this->owner = desc.owner;
|
||||
|
||||
Oyster::Callback::OysterCallback<void, NetworkSession::NetEvent> c;
|
||||
c.value.callbackPostBox = this->box;
|
||||
c.callbackType = Oyster::Callback::CallbackType_PostBox;
|
||||
|
||||
for (unsigned int i = 0; i < desc.clients.Size(); i++)
|
||||
{
|
||||
this->clients[i] = new GameClient(desc.clients[i], gameInstance.CreatePlayer(), c);
|
||||
}
|
||||
|
||||
if(this->worker.Create(this, true, true) != OYSTER_THREAD_ERROR_SUCCESS) return false;
|
||||
|
||||
this->isCreated = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void GameSession::Run()
|
||||
{
|
||||
|
||||
if(this->isRunning) return;
|
||||
|
||||
if(this->clients.Size() > 0)
|
||||
{
|
||||
|
||||
this->worker.SetPriority(OYSTER_THREAD_PRIORITY_2);
|
||||
this->isRunning = true;
|
||||
}
|
||||
}
|
||||
|
||||
bool GameSession::Join(Utility::DynamicMemory::SmartPointer<LobbyClient> client)
|
||||
{
|
||||
if(!this->isCreated) return false;
|
||||
|
||||
Oyster::Callback::OysterCallback<void, DanBias::NetworkSession::NetEvent> c;
|
||||
c.value.callbackPostBox = this->box;
|
||||
c.callbackType = Oyster::Callback::CallbackType_PostBox;
|
||||
|
||||
SmartPointer<GameClient> obj = new GameClient(client, this->gameInstance.CreatePlayer(), c);
|
||||
AddClient(obj);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void GameSession::CloseSession(bool dissconnectClients)
|
||||
{
|
||||
if(dissconnectClients)
|
||||
{
|
||||
for (int i = 0; i < this->clients.Size(); i++)
|
||||
{
|
||||
this->clients[i]->GetClient()->Disconnect();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this->SendToOwner(0); //Send all clients to the current owner
|
||||
}
|
||||
this->Clean();
|
||||
}
|
||||
|
||||
void GameSession::AddClient(SmartPointer<GameClient> obj)
|
||||
{
|
||||
for (unsigned int i = 0; i < clients.Size(); i++)
|
||||
{
|
||||
if(!clients[i])
|
||||
{
|
||||
clients[i] = obj;
|
||||
return;
|
||||
}
|
||||
}
|
||||
clients.Push(obj);
|
||||
}
|
||||
|
||||
void GameSession::RemoveClient(DanBias::GameClient* obj)
|
||||
{
|
||||
for (unsigned int i = 0; i < clients.Size(); i++)
|
||||
{
|
||||
if(clients[i] && clients[i]->GetID() == obj->GetID())
|
||||
{
|
||||
clients[i] = 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GameSession::SendToOwner(DanBias::GameClient* obj)
|
||||
{
|
||||
DanBias::NetworkSession *s = GameServer::MainLobbyInstance();
|
||||
|
||||
if(this->owner) s = this->owner;
|
||||
|
||||
if(obj)
|
||||
{
|
||||
s->Attach(obj->ReleaseClient());
|
||||
RemoveClient(obj);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < this->clients.Size(); i++)
|
||||
{
|
||||
if(this->clients[i])
|
||||
{
|
||||
s->Attach(this->clients[i]->ReleaseClient());
|
||||
RemoveClient(this->clients[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GameSession::Clean()
|
||||
{
|
||||
this->worker.Terminate();
|
||||
this->clients.Clear();
|
||||
delete this->box;
|
||||
this->box = 0;
|
||||
this->gameInstance;
|
||||
this->owner = 0;
|
||||
this->isCreated = false;
|
||||
this->isRunning = false;
|
||||
}
|
||||
|
||||
}//End namespace DanBias
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
/////////////////////////////////////////////////////////////////////
|
||||
// Created by [Dennis Andersen] [2013]
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
#include "GameSession.h"
|
||||
#include "GameClient.h"
|
||||
|
||||
#include <Protocols.h>
|
||||
#include <PostBox\PostBox.h>
|
||||
#include <GameLogicStates.h>
|
||||
#include <Windows.h>
|
||||
#include <OysterMath.h>
|
||||
|
||||
using namespace Utility::DynamicMemory;
|
||||
using namespace Oyster;
|
||||
using namespace Oyster::Network;
|
||||
using namespace Oyster::Thread;
|
||||
using namespace GameLogic;
|
||||
|
||||
namespace DanBias
|
||||
{
|
||||
bool GameSession::DoWork( )
|
||||
{
|
||||
this->gameInstance.NewFrame();
|
||||
|
||||
this->ParseEvents();
|
||||
|
||||
if(GetAsyncKeyState(VK_UP))
|
||||
{
|
||||
Protocol_General_Status p(Protocol_General_Status::States_ready);
|
||||
Send(p.GetProtocol());
|
||||
Sleep(100);
|
||||
}
|
||||
if(GetAsyncKeyState(VK_DOWN))
|
||||
{
|
||||
Oyster::Math::Float4x4 world = Oyster::Math::Matrix::identity;
|
||||
Protocol_CreateObject p(world, 2, "../Content/crate");
|
||||
Send(p.GetProtocol());
|
||||
Sleep(100);
|
||||
}
|
||||
|
||||
return this->isRunning;
|
||||
}
|
||||
|
||||
}//End namespace DanBias
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
/////////////////////////////////////////////////////////////////////
|
||||
// Created by [Dennis Andersen] [2013]
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
#include "GameSession.h"
|
||||
#include "GameClient.h"
|
||||
|
||||
#include <Protocols.h>
|
||||
#include <PostBox\PostBox.h>
|
||||
#include <GameLogicStates.h>
|
||||
#include <Windows.h>
|
||||
|
||||
using namespace Utility::DynamicMemory;
|
||||
using namespace Oyster;
|
||||
using namespace Oyster::Network;
|
||||
using namespace Oyster::Thread;
|
||||
using namespace GameLogic;
|
||||
|
||||
namespace DanBias
|
||||
{
|
||||
void GameSession::Send(Oyster::Network::CustomNetProtocol* p)
|
||||
{
|
||||
for (unsigned int i = 0; i < this->clients.Size(); i++)
|
||||
{
|
||||
if(this->clients[i] && this->clients[i]->GetClient())
|
||||
this->clients[i]->GetClient()->Send(p);
|
||||
}
|
||||
}
|
||||
}//End namespace DanBias
|
||||
|
|
@ -1,3 +1,6 @@
|
|||
/////////////////////////////////////////
|
||||
// Created by [Dennis Andersen] [2013] //
|
||||
/////////////////////////////////////////
|
||||
#ifndef DANBIASSERVER_LEVELMANAGER_H
|
||||
#define DANBIASSERVER_LEVELMANAGER_H
|
||||
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
/////////////////////////////////////////
|
||||
// Created by [Dennis Andersen] [2013] //
|
||||
/////////////////////////////////////////
|
||||
#ifndef DANBIASSERVER_INETWORKSESSION_H
|
||||
#define DANBIASSERVER_INETWORKSESSION_H
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "LobbyClient.h"
|
||||
#include <GameProtocols.h>
|
||||
#include <Protocols.h>
|
||||
|
||||
using namespace Utility::DynamicMemory;
|
||||
using namespace Oyster::Network;
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
/////////////////////////////////////////
|
||||
// Created by [Dennis Andersen] [2013] //
|
||||
/////////////////////////////////////////
|
||||
#ifndef DANBIASSERVER_LOBBYCLIENT_H
|
||||
#define DANBIASSERVER_LOBBYCLIENT_H
|
||||
|
||||
|
|
|
@ -19,11 +19,12 @@ namespace DanBias
|
|||
}
|
||||
MainLobby::~MainLobby()
|
||||
{
|
||||
delete this->box;
|
||||
this->box = 0;
|
||||
|
||||
}
|
||||
void MainLobby::Release()
|
||||
{
|
||||
delete this->box;
|
||||
this->box = 0;
|
||||
this->CloseSession(true);
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include "NetworkSession.h"
|
||||
#include "GameLobby.h"
|
||||
#include <GameProtocols.h>
|
||||
#include <Protocols.h>
|
||||
#include <PostBox\IPostBox.h>
|
||||
|
||||
namespace DanBias
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//////////////////////////////////////////////////
|
||||
// Launcher to launch Danbias server or client //
|
||||
// Launcher to launch Danbias server //
|
||||
// Created by [Dennis Andersen] [2013] //
|
||||
//////////////////////////////////////////////////
|
||||
#define NOMINMAX //Blame it on windows
|
||||
|
|
|
@ -9,9 +9,7 @@
|
|||
|
||||
namespace GameLogic
|
||||
{
|
||||
|
||||
|
||||
class DANBIAS_GAMELOGIC_DLL DynamicObject : public Object
|
||||
class DynamicObject : public Object
|
||||
{
|
||||
|
||||
public:
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "Game.h"
|
||||
#include "Player.h"
|
||||
#include "Level.h"
|
||||
#include <GID.h>
|
||||
|
||||
using namespace GameLogic;
|
||||
|
||||
|
|
|
@ -1,10 +1,16 @@
|
|||
/////////////////////////////////////////////////////////////////////
|
||||
// Created by [Erik Persson] [2013]
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef GAME_H
|
||||
#define GAME_H
|
||||
|
||||
#include "GameLogicDef.h"
|
||||
#include "GameLogicStates.h"
|
||||
|
||||
namespace GameLogic
|
||||
{
|
||||
class Game
|
||||
class DANBIAS_GAMELOGIC_DLL Game
|
||||
{
|
||||
|
||||
public:
|
||||
|
|
|
@ -8,12 +8,11 @@
|
|||
|
||||
|
||||
#include "GameLogicStates.h"
|
||||
#include "GameLogicDef.h"
|
||||
#include <PhysicsAPI.h>
|
||||
|
||||
namespace GameLogic
|
||||
{
|
||||
class DANBIAS_GAMELOGIC_DLL Object
|
||||
class Object
|
||||
{
|
||||
public:
|
||||
Object();
|
||||
|
|
|
@ -132,7 +132,7 @@ Oyster::Math::Float3 Player::GetPos()
|
|||
|
||||
Oyster::Math::Float3 Player::GetLookDir()
|
||||
{
|
||||
return myData->lookDir;
|
||||
return myData->lookDir.xyz;
|
||||
}
|
||||
|
||||
int Player::GetTeamID()
|
||||
|
|
|
@ -4,14 +4,13 @@
|
|||
#ifndef PLAYER_H
|
||||
#define PLAYER_H
|
||||
#include "GameLogicStates.h"
|
||||
#include "GameLogicDef.h"
|
||||
#include "OysterMath.h"
|
||||
#include "Object.h"
|
||||
|
||||
|
||||
namespace GameLogic
|
||||
{
|
||||
class DANBIAS_GAMELOGIC_DLL Player : public Object
|
||||
class Player : public Object
|
||||
{
|
||||
|
||||
public:
|
||||
|
|
|
@ -13,6 +13,7 @@ namespace GameLogic
|
|||
States_ready,
|
||||
States_idle,
|
||||
States_bussy,
|
||||
State_waiting,
|
||||
States_disconected,
|
||||
};
|
||||
States status;
|
||||
|
|
|
@ -155,7 +155,8 @@
|
|||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="ControlProtocols.h" />
|
||||
<ClInclude Include="GameProtocols.h" />
|
||||
<ClInclude Include="GameplayProtocols.h" />
|
||||
<ClInclude Include="Protocols.h" />
|
||||
<ClInclude Include="LobbyProtocols.h" />
|
||||
<ClInclude Include="ObjectProtocols.h" />
|
||||
<ClInclude Include="PlayerProtocols.h" />
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
#ifndef GAMEPROTOCOLS_GAMEPLAYPROTOCOLS_H
|
||||
#define GAMEPROTOCOLS_GAMEPLAYPROTOCOLS_H
|
||||
|
||||
#include <vector>
|
||||
#include <CustomNetProtocol.h>
|
||||
#include "ProtocolIdentificationID.h"
|
||||
|
||||
namespace GameLogic
|
||||
{
|
||||
struct Protocol_GameplayInitiateSession :public Oyster::Network::CustomProtocolObject
|
||||
{
|
||||
struct SessionInitData
|
||||
{
|
||||
int id;
|
||||
int type;
|
||||
//std::string text;
|
||||
};
|
||||
std::vector<SessionInitData> element;
|
||||
|
||||
Protocol_GameplayInitiateSession()
|
||||
{
|
||||
this->protocol[protocol_INDEX_ID].value = protocol_Gameplay_Initiate;
|
||||
this->protocol[protocol_INDEX_ID].type = Oyster::Network::NetAttributeType_Short;
|
||||
}
|
||||
Protocol_GameplayInitiateSession(Oyster::Network::CustomNetProtocol& p)
|
||||
{
|
||||
int size = p[1].value.netInt;
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
SessionInitData d = { p[i+2].value.netInt, p[i+3].value.netInt /*, p[i+4].value.netCharPtr */ };
|
||||
element.push_back(d);
|
||||
}
|
||||
}
|
||||
void Add(int id, int type, std::string text)
|
||||
{
|
||||
SessionInitData d = { id, type /*, text*/ };
|
||||
element.push_back(d);
|
||||
}
|
||||
Oyster::Network::CustomNetProtocol* GetProtocol() override
|
||||
{
|
||||
//Store the elements count
|
||||
this->protocol[1].value = element.size();
|
||||
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
|
||||
|
||||
for (unsigned int i = 0; i < element.size(); i+=3)
|
||||
{
|
||||
this->protocol[i+2].value = element[i].id;
|
||||
this->protocol[i+3].value = element[i].type;
|
||||
//element[i].text.copy(this->protocol[i+4].value.netCharPtr, element[i].text.size());
|
||||
|
||||
this->protocol[i+2].type = Oyster::Network::NetAttributeType_Int;
|
||||
this->protocol[i+3].type = Oyster::Network::NetAttributeType_Int;
|
||||
//this->protocol[i+4].type = Oyster::Network::NetAttributeType_CharArray;
|
||||
}
|
||||
return &protocol;
|
||||
}
|
||||
|
||||
private:
|
||||
Oyster::Network::CustomNetProtocol protocol;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // !GAMEPROTOCOLS_GAMEPLAYPROTOCOLS_H
|
|
@ -22,7 +22,7 @@
|
|||
/***********************************/
|
||||
/********* GENERAL PROTOCOLS ***************************************************************************************************/
|
||||
/***********[ 100 - 200 ]***********/
|
||||
#define protocol_GeneralMIN 100 /* This defines lower bounds of general protocols (okay to have same value on first element). */
|
||||
#define protocol_GeneralMIN 100
|
||||
#define protocol_General_Status 100
|
||||
#define protocol_General_Text 101
|
||||
#define protocol_GeneralMAX 199
|
||||
|
@ -51,6 +51,7 @@
|
|||
#define protocol_Gameplay_CreateObject 303
|
||||
#define protocol_Gameplay_RemoveObject 304
|
||||
#define protocol_Gameplay_ObjectPosition 305
|
||||
#define protocol_Gameplay_Initiate 306
|
||||
#define protocol_GameplayMAX 399
|
||||
|
||||
|
||||
|
@ -61,11 +62,4 @@ inline bool ProtocolIsLobby(short ID) { return (ID >= protocol_LobbyMIN && ID <=
|
|||
inline bool ProtocolIsGeneral(short ID) { return (ID >= protocol_GeneralMIN && ID <= protocol_GeneralMAX); }
|
||||
inline bool ProtocolIsGameplay(short ID) { return (ID >= protocol_GameplayMIN && ID <= protocol_GameplayMAX); }
|
||||
|
||||
|
||||
|
||||
/***********************************/
|
||||
/*********** TEST PROTOCOLS *******************************************************************************************************/
|
||||
/***********[ x - x ]************/
|
||||
|
||||
|
||||
#endif // !GAMEPROTOCOL_PROTOCOL_DEFINITION_ID_H
|
||||
|
|
|
@ -5,5 +5,6 @@
|
|||
#include "PlayerProtocols.h"
|
||||
#include "LobbyProtocols.h"
|
||||
#include "ControlProtocols.h"
|
||||
#include "GameplayProtocols.h"
|
||||
|
||||
#endif // !GAMEPROTOCOLS_GAMEPROTOCOLS_H
|
|
@ -71,13 +71,13 @@ namespace Oyster
|
|||
//OYSTER_THREAD_ERROR Create(Oyster::Callback::CallbackObject<bool, void>* worker, bool start, bool detach = false);
|
||||
//OYSTER_THREAD_ERROR Create(Oyster::Callback::CallbackFunction<bool, void>::FNC worker, bool start, bool detach = false);
|
||||
OYSTER_THREAD_ERROR Start();
|
||||
OYSTER_THREAD_ERROR Stop(bool wait = false);
|
||||
OYSTER_THREAD_ERROR Stop();
|
||||
OYSTER_THREAD_ERROR Pause();
|
||||
OYSTER_THREAD_ERROR Pause(int mSec);
|
||||
OYSTER_THREAD_ERROR Resume();
|
||||
OYSTER_THREAD_ERROR SetWorker(IThreadObject* worker = 0);
|
||||
OYSTER_THREAD_ERROR SetWorker(ThreadFnc worker = 0);
|
||||
OYSTER_THREAD_ERROR Terminate(bool wait = true);
|
||||
OYSTER_THREAD_ERROR Terminate();
|
||||
OYSTER_THREAD_ERROR Wait();
|
||||
OYSTER_THREAD_ERROR Wait(int mSec);
|
||||
OYSTER_THREAD_ERROR Swap(const OysterThread* other);
|
||||
|
|
|
@ -15,8 +15,6 @@ using namespace Oyster::Thread;
|
|||
using namespace Utility::DynamicMemory;
|
||||
|
||||
|
||||
|
||||
|
||||
#pragma region Declerations
|
||||
|
||||
enum OYSTER_THREAD_STATE
|
||||
|
@ -51,8 +49,8 @@ using namespace Utility::DynamicMemory;
|
|||
OwnerContainer ownerObj; //
|
||||
std::atomic<int> msec; //<! A timer in miliseconds.
|
||||
|
||||
std::timed_mutex threadFunctionLock;
|
||||
//std::mutex threadWaitFunctionLock;
|
||||
//std::timed_mutex threadFunctionLock;
|
||||
std::mutex threadStopMutex;
|
||||
};
|
||||
|
||||
/** A typical Oyster thread function */
|
||||
|
@ -60,8 +58,9 @@ using namespace Utility::DynamicMemory;
|
|||
|
||||
struct RefData
|
||||
{
|
||||
//std::mutex threadWaitFunctionLock;
|
||||
std::mutex threadWaitFunctionLock;
|
||||
bool isCreated;
|
||||
bool isAlive;
|
||||
ThreadData *threadData;
|
||||
std::thread workerThread;
|
||||
|
||||
|
@ -73,78 +72,29 @@ using namespace Utility::DynamicMemory;
|
|||
~RefData()
|
||||
{
|
||||
//threadWaitFunctionLock.lock();
|
||||
Terminate(true);
|
||||
Terminate();
|
||||
//threadWaitFunctionLock.unlock();
|
||||
}
|
||||
OYSTER_THREAD_ERROR Terminate(bool wait)
|
||||
OYSTER_THREAD_ERROR Terminate()
|
||||
{
|
||||
if(!threadData) return OYSTER_THREAD_ERROR_SUCCESS;
|
||||
|
||||
this->threadData->state = OYSTER_THREAD_STATE_DEAD;
|
||||
|
||||
if(wait)
|
||||
if(this->workerThread.joinable())
|
||||
{
|
||||
if(std::this_thread::get_id() != this->workerThread.get_id())
|
||||
if(this->workerThread.joinable())
|
||||
{
|
||||
this->workerThread.join();
|
||||
this->isCreated = false;
|
||||
this->threadData = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(this->workerThread.joinable())
|
||||
this->workerThread.detach();
|
||||
this->workerThread.join();
|
||||
this->isCreated = false;
|
||||
delete this->threadData;
|
||||
this->threadData = 0;
|
||||
}
|
||||
|
||||
return OYSTER_THREAD_ERROR_SUCCESS;
|
||||
}
|
||||
//OYSTER_THREAD_ERROR Create(ThreadFunction fnc, IThreadObject* worker, bool start, bool detach)
|
||||
//{
|
||||
// if(this->isCreated ) return OYSTER_THREAD_ERROR_ThreadAlreadyCreated;
|
||||
//
|
||||
// threadData = new ThreadData();
|
||||
// if(start)
|
||||
// this->threadData->state = OYSTER_THREAD_STATE_NORMAL;
|
||||
// else
|
||||
// this->threadData->state = OYSTER_THREAD_STATE_IDLE;
|
||||
// threadData->owner = worker;
|
||||
// threadData->prio = OYSTER_THREAD_PRIORITY_3;
|
||||
//
|
||||
// workerThread = std::thread(fnc, this->threadData);
|
||||
//
|
||||
// if(detach)
|
||||
// this->workerThread.detach();
|
||||
//
|
||||
// isCreated = true;
|
||||
//
|
||||
// return OYSTER_THREAD_ERROR_SUCCESS;
|
||||
//}
|
||||
//OYSTER_THREAD_ERROR Create(ThreadFunction fnc, Oyster::Callback::OysterCallback<bool, void> worker, bool start, bool detach)
|
||||
//{
|
||||
// if(this->isCreated ) return OYSTER_THREAD_ERROR_ThreadAlreadyCreated;
|
||||
//
|
||||
// threadData = new ThreadData();
|
||||
// if(start)
|
||||
// this->threadData->state = OYSTER_THREAD_STATE_NORMAL;
|
||||
// else
|
||||
// this->threadData->state = OYSTER_THREAD_STATE_IDLE;
|
||||
// threadData->ownerObj = worker;
|
||||
// threadData->prio = OYSTER_THREAD_PRIORITY_3;
|
||||
//
|
||||
// workerThread = std::thread(fnc, this->threadData);
|
||||
//
|
||||
// if(detach)
|
||||
// this->workerThread.detach();
|
||||
//
|
||||
// isCreated = true;
|
||||
//
|
||||
// return OYSTER_THREAD_ERROR_SUCCESS;
|
||||
//}
|
||||
OYSTER_THREAD_ERROR Create(ThreadFunction fnc, OwnerContainer worker, bool start, bool detach)
|
||||
{
|
||||
if(this->isCreated ) return OYSTER_THREAD_ERROR_ThreadAlreadyCreated;
|
||||
|
||||
|
||||
threadData = new ThreadData();
|
||||
if(start)
|
||||
this->threadData->state = OYSTER_THREAD_STATE_NORMAL;
|
||||
|
@ -155,8 +105,8 @@ using namespace Utility::DynamicMemory;
|
|||
|
||||
workerThread = std::thread(fnc, this->threadData);
|
||||
|
||||
if(detach)
|
||||
this->workerThread.detach();
|
||||
//if(detach)
|
||||
// this->workerThread.detach();
|
||||
|
||||
isCreated = true;
|
||||
|
||||
|
@ -171,9 +121,7 @@ using namespace Utility::DynamicMemory;
|
|||
PrivateData(){}
|
||||
~PrivateData()
|
||||
{
|
||||
if(data)
|
||||
if(data->threadData)
|
||||
memset(&data->threadData->ownerObj, 0, sizeof(OwnerContainer));
|
||||
data.Release();
|
||||
}
|
||||
OYSTER_THREAD_ERROR Create(ThreadFunction fnc, OwnerContainer worker, bool start, bool detach)
|
||||
{
|
||||
|
@ -181,12 +129,12 @@ using namespace Utility::DynamicMemory;
|
|||
data = new RefData();
|
||||
return data->Create(fnc, worker, start, detach);
|
||||
}
|
||||
OYSTER_THREAD_ERROR Terminate(bool wait)
|
||||
OYSTER_THREAD_ERROR Terminate()
|
||||
{
|
||||
if(!data)
|
||||
return OYSTER_THREAD_ERROR_FAILED;
|
||||
|
||||
return data->Terminate(wait);
|
||||
return data->Terminate();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -248,7 +196,8 @@ using namespace Utility::DynamicMemory;
|
|||
if(w->ownerObj.value.obj) w->ownerObj.value.obj->ThreadExit();
|
||||
|
||||
w->state = OYSTER_THREAD_STATE_DEAD;
|
||||
delete w;
|
||||
|
||||
//delete w;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -295,31 +244,6 @@ OYSTER_THREAD_ERROR OysterThread::Create(ThreadFnc worker, bool start, bool deta
|
|||
return this->privateData->Create(ThreadHelp::ThreadingFunction, c, start, detach);
|
||||
}
|
||||
|
||||
/*
|
||||
OYSTER_THREAD_ERROR OysterThread::Create(Oyster::Callback::CallbackObject<bool, void>* worker, bool start, bool detach)
|
||||
{
|
||||
if(!this->privateData)
|
||||
this->privateData = new PrivateData();
|
||||
|
||||
Oyster::Callback::OysterCallback<> temp;
|
||||
temp.callbackType = Oyster::Callback::CallbackType_Object;
|
||||
temp.value = worker;
|
||||
|
||||
return this->privateData->Create(ThreadHelp::ThreadingFunction, temp, start, detach);
|
||||
}
|
||||
OYSTER_THREAD_ERROR OysterThread::Create(Oyster::Callback::CallbackFunction<bool, void>::FNC worker, bool start, bool detach)
|
||||
{
|
||||
if(!this->privateData)
|
||||
this->privateData = new PrivateData();
|
||||
|
||||
Oyster::Callback::OysterCallback<> temp;
|
||||
temp.callbackType = Oyster::Callback::CallbackType_Function;
|
||||
temp.value = worker;
|
||||
|
||||
return this->privateData->Create(ThreadHelp::ThreadingFunction, temp, start, detach);
|
||||
}
|
||||
*/
|
||||
|
||||
OYSTER_THREAD_ERROR OysterThread::Start()
|
||||
{
|
||||
if(!this->privateData->data->threadData->ownerObj)
|
||||
|
@ -332,9 +256,9 @@ OYSTER_THREAD_ERROR OysterThread::Start()
|
|||
|
||||
return OYSTER_THREAD_ERROR_SUCCESS;
|
||||
}
|
||||
OYSTER_THREAD_ERROR OysterThread::Stop(bool wait)
|
||||
OYSTER_THREAD_ERROR OysterThread::Stop()
|
||||
{
|
||||
return this->Terminate(wait);
|
||||
return this->Terminate();
|
||||
}
|
||||
OYSTER_THREAD_ERROR OysterThread::Pause()
|
||||
{
|
||||
|
@ -373,9 +297,9 @@ OYSTER_THREAD_ERROR OysterThread::SetWorker(ThreadFnc worker)
|
|||
|
||||
return OYSTER_THREAD_ERROR_SUCCESS;;
|
||||
}
|
||||
OYSTER_THREAD_ERROR OysterThread::Terminate(bool wait)
|
||||
OYSTER_THREAD_ERROR OysterThread::Terminate()
|
||||
{
|
||||
return this->privateData->Terminate(wait);
|
||||
return this->privateData->Terminate();
|
||||
}
|
||||
OYSTER_THREAD_ERROR OysterThread::Wait()
|
||||
{
|
||||
|
@ -384,9 +308,6 @@ OYSTER_THREAD_ERROR OysterThread::Wait()
|
|||
|
||||
if( this->privateData->data->workerThread.get_id() == std::this_thread::get_id())
|
||||
return OYSTER_THREAD_ERROR_ThreadCannotWaintOnItselfe;
|
||||
|
||||
//this->privateData->data->threadData->threadFunctionLock.lock();
|
||||
//this->privateData->data->threadData->threadFunctionLock.unlock();
|
||||
|
||||
return OYSTER_THREAD_ERROR_SUCCESS;
|
||||
}
|
||||
|
@ -394,9 +315,6 @@ OYSTER_THREAD_ERROR OysterThread::Wait(int msec)
|
|||
{
|
||||
if(this->privateData->data->workerThread.get_id() == std::this_thread::get_id())
|
||||
return OYSTER_THREAD_ERROR_ThreadCannotWaintOnItselfe;
|
||||
|
||||
//if(this->privateData->data->threadData->threadFunctionLock.try_lock_for(std::chrono::milliseconds(msec)))
|
||||
// this->privateData->data->threadData->threadFunctionLock.unlock();
|
||||
|
||||
return OYSTER_THREAD_ERROR_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -292,7 +292,8 @@ namespace Utility
|
|||
|
||||
this->_ptr = p;
|
||||
|
||||
if(p) this->_rc->Incref();
|
||||
if(p) this->_rc->Incref();
|
||||
else this->_rc = 0;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
|
|
@ -63,9 +63,8 @@ struct ClientDataContainer
|
|||
}
|
||||
~ClientDataContainer()
|
||||
{
|
||||
thread.Stop();
|
||||
thread.Wait();
|
||||
connection.Disconnect();
|
||||
thread.Stop();
|
||||
callbackType = NetworkProtocolCallbackType_Unknown;
|
||||
|
||||
ShutdownWinSock();
|
||||
|
@ -244,6 +243,7 @@ bool NetworkClient::Connect(unsigned short port, const char serverIP[])
|
|||
void NetworkClient::Disconnect()
|
||||
{
|
||||
privateData->data->connection.Disconnect();
|
||||
privateData->data->thread.Terminate();
|
||||
}
|
||||
|
||||
bool NetworkClient::IsConnected()
|
||||
|
|
|
@ -115,7 +115,7 @@ void NetworkServer::PrivateData::Stop()
|
|||
|
||||
started = false;
|
||||
|
||||
thread.Stop(true);
|
||||
thread.Stop();
|
||||
}
|
||||
|
||||
void NetworkServer::PrivateData::Shutdown()
|
||||
|
|
|
@ -108,6 +108,7 @@ int Connection::InitiateClient()
|
|||
|
||||
int Connection::Disconnect()
|
||||
{
|
||||
if(this->closed) return -1;
|
||||
int val = CloseSocket(this->socket);
|
||||
this->socket = -1;
|
||||
this->closed = true;
|
||||
|
@ -117,6 +118,8 @@ int Connection::Disconnect()
|
|||
|
||||
int Connection::Send(OysterByte &bytes)
|
||||
{
|
||||
if(this->closed) return -1;
|
||||
|
||||
int nBytes;
|
||||
|
||||
nBytes = send(this->socket, bytes, bytes.GetSize(), 0);
|
||||
|
@ -130,6 +133,7 @@ int Connection::Send(OysterByte &bytes)
|
|||
|
||||
int Connection::Recieve(OysterByte &bytes)
|
||||
{
|
||||
if(this->closed) return -1;
|
||||
int nBytes;
|
||||
|
||||
bytes.Resize(1000);
|
||||
|
@ -150,6 +154,8 @@ int Connection::Recieve(OysterByte &bytes)
|
|||
//Listen will only return the correct socket or -1 for failure.
|
||||
int Connection::Listen()
|
||||
{
|
||||
if(this->closed) return -1;
|
||||
|
||||
int clientSocket;
|
||||
if((clientSocket = (int)accept(this->socket, NULL, NULL)) == INVALID_SOCKET)
|
||||
{
|
||||
|
|
|
@ -6,11 +6,14 @@ using namespace Oyster::Thread;
|
|||
|
||||
Listener::Listener()
|
||||
{
|
||||
this->port = -1;
|
||||
this->isListening = false;
|
||||
connection = NULL;
|
||||
}
|
||||
|
||||
Listener::Listener(Oyster::Network::IPostBox<int>* postBox)
|
||||
{
|
||||
this->isListening = false;
|
||||
connection = NULL;
|
||||
this->postBox = postBox;
|
||||
}
|
||||
|
@ -19,9 +22,11 @@ Listener::~Listener()
|
|||
{
|
||||
if(connection)
|
||||
{
|
||||
this->thread.Terminate(false);
|
||||
this->isListening = false;
|
||||
this->thread.Terminate();
|
||||
delete connection;
|
||||
connection = 0;
|
||||
this->port = -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -36,6 +41,8 @@ bool Listener::Init(unsigned int port)
|
|||
return false;
|
||||
}
|
||||
|
||||
this->port = port;
|
||||
this->isListening = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -52,6 +59,11 @@ bool Listener::Init(unsigned int port, bool start)
|
|||
return false;
|
||||
}
|
||||
|
||||
if(start)
|
||||
{
|
||||
this->isListening = true;
|
||||
}
|
||||
this->port = port;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -62,17 +74,18 @@ bool Listener::Start()
|
|||
return false;
|
||||
}
|
||||
|
||||
this->isListening = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
void Listener::Stop()
|
||||
{
|
||||
thread.Stop();
|
||||
StopListen();
|
||||
}
|
||||
|
||||
void Listener::Shutdown()
|
||||
{
|
||||
thread.Stop(false);
|
||||
StopListen();
|
||||
}
|
||||
|
||||
void Listener::SetPostBox(Oyster::Network::IPostBox<int>* postBox)
|
||||
|
@ -87,6 +100,10 @@ int Listener::Accept()
|
|||
int clientSocket = -1;
|
||||
clientSocket = connection->Listen();
|
||||
|
||||
if(!this->isListening.load())
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
if(clientSocket != -1)
|
||||
{
|
||||
stdMutex.lock();
|
||||
|
@ -96,13 +113,26 @@ int Listener::Accept()
|
|||
|
||||
return clientSocket;
|
||||
}
|
||||
|
||||
void Listener::StopListen()
|
||||
{
|
||||
if(this->connection && this->connection->IsConnected())
|
||||
{
|
||||
this->isListening = false;
|
||||
Connection c;
|
||||
c.InitiateClient();
|
||||
c.Connect(this->port, "127.0.0.1");
|
||||
}
|
||||
}
|
||||
bool Listener::DoWork()
|
||||
{
|
||||
if(!this->connection) return false;
|
||||
int result = Accept();
|
||||
|
||||
if(result == -1)
|
||||
if(!this->isListening.load())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if(result == -1)
|
||||
{
|
||||
//Do something?
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "../../Misc/Thread/OysterThread.h"
|
||||
#include "../../Misc/Thread/OysterMutex.h"
|
||||
#include "../../Misc/Utilities.h"
|
||||
#include <atomic>
|
||||
|
||||
namespace Oyster
|
||||
{
|
||||
|
@ -41,6 +42,7 @@ namespace Oyster
|
|||
|
||||
//Function that runs in the thread.
|
||||
int Accept();
|
||||
void StopListen();
|
||||
|
||||
private:
|
||||
::Oyster::Network::Connection* connection;
|
||||
|
@ -50,7 +52,8 @@ namespace Oyster
|
|||
std::mutex stdMutex;
|
||||
|
||||
IPostBox<int>* postBox;
|
||||
|
||||
std::atomic<bool> isListening;
|
||||
int port;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,9 +9,11 @@ namespace Oyster
|
|||
{
|
||||
namespace Model
|
||||
{
|
||||
//struct ModelInfo;
|
||||
struct Model
|
||||
{
|
||||
//! do not Edit, linked to render data
|
||||
//ModelInfo* info;
|
||||
void* info;
|
||||
Oyster::Math::Float4x4 WorldMatrix;
|
||||
bool Visible;
|
||||
|
|
|
@ -32,7 +32,7 @@ public:
|
|||
{
|
||||
parent = 0;
|
||||
hInstance = NULL;
|
||||
windowName = L"おはよう";
|
||||
windowName = L"Window";
|
||||
windowSize.x = 800;
|
||||
windowSize.y = 600;
|
||||
windowPosition.x = 0;
|
||||
|
|
Loading…
Reference in New Issue