Skip to content

Commit

Permalink
feat: fx server compatability
Browse files Browse the repository at this point in the history
I've had to change the websocket library to one that is PCL compatiable.

Main changes are that this version now works with FX server (only tested on 374)

New socket server
1. Now uses the "deniszykov.WebSocketListener" library for that shiz (touches #4)

closes #1
  • Loading branch information
TGRHavoc committed May 17, 2019
1 parent 9de1ccd commit fee9958
Show file tree
Hide file tree
Showing 15 changed files with 326 additions and 285 deletions.
File renamed without changes.
11 changes: 6 additions & 5 deletions __resource.lua
@@ -1,9 +1,10 @@
resource_manifest_version "44febabe-d386-4d18-afbe-5e627f4af937"

client_script("client.lua")
client_scripts{
"client/client.lua"
}

server_scripts {
"blips.lua",
"blip_helper.lua",
"live.lua"
server_scripts{
"server/live_map.net.dll",
"server/wrapper.lua"
}
Binary file added deniszykov.WebSocketListener.dll
Binary file not shown.
Binary file removed libs/Live Map.dll
Binary file not shown.
11 changes: 0 additions & 11 deletions libs/Live Map.dll.config

This file was deleted.

Binary file removed libs/Live Map.pdb
Binary file not shown.
Binary file removed libs/websocket-sharp.dll
Binary file not shown.
Binary file added server/live_map.net.dll
Binary file not shown.
50 changes: 50 additions & 0 deletions server/wrapper.lua
@@ -0,0 +1,50 @@
--[[
Simple file that wraps all the internal events so that they can just be called
by the client without any extra steps needed by the end-developer :)
]]

RegisterServerEvent("livemap:AddPlayerData")
RegisterServerEvent("livemap:UpdatePlayerData")

RegisterServerEvent("livemap:playerSpawned")

AddEventHandler("livemap:AddPlayerData", function(k, d)
local id = GetPlayerIdentifier(source, 0) -- Get the first id, it'll do
print("Adding data for " .. id)

TriggerEvent("livemap:internal_AddPlayerData", id, k, d)
end)

AddEventHandler("livemap:UpdatePlayerData", function(k, d)
local id = GetPlayerIdentifier(source, 0) -- Get the first id, it'll do
print("Updating data for " .. id)

TriggerEvent("livemap:internal_UpdatePlayerData", id, k, d)
end)


function setStaticDataFor(index, id)
TriggerEvent("livemap:internal_AddPlayerData", id, "identifer", id)
TriggerEvent("livemap:internal_AddPlayerData", id, "name", GetPlayerName(index))
end

--[[
Set some static data that isn't going to change
e.g. Player's Identifer
]]
AddEventHandler("livemap:playerSpawned", function()
local id = GetPlayerIdentifier(source, 0) -- Get the first id, it'll do
setStaticDataFor(source, id)
end)

-- If any players are already on the server
AddEventHandler("onResourceStart", function(name)
if name == GetCurrentResourceName() then
if GetNumPlayerIndices() ~= -1 then
for i=0, GetNumPlayerIndices()-1 do
local id = GetPlayerIdentifier(GetPlayerFromIndex(i), 0)
setStaticDataFor(GetPlayerFromIndex(i), id)
end
end
end
end)
24 changes: 15 additions & 9 deletions src/Live Map/Live Map.csproj
Expand Up @@ -7,8 +7,8 @@
<ProjectGuid>{15269C18-91AF-4129-8FA0-3601D1B0C6D2}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Live_Map</RootNamespace>
<AssemblyName>Live Map</AssemblyName>
<RootNamespace>Havoc.Live_Map</RootNamespace>
<AssemblyName>live_map.net</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
Expand All @@ -30,8 +30,12 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="CitizenMP.Server">
<HintPath>F:\cfx-server\CitizenMP.Server.exe</HintPath>
<Reference Include="CitizenFX.Core">
<HintPath>F:\fx-artifacts\374\citizen\clr2\lib\mono\4.5\CitizenFX.Core.dll</HintPath>
</Reference>
<Reference Include="deniszykov.WebSocketListener, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7f78616efb4a208d, processorArchitecture=MSIL">
<HintPath>..\packages\deniszykov.WebSocketListener.4.0.0\lib\net45\deniszykov.WebSocketListener.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.10.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
Expand All @@ -45,21 +49,23 @@
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="websocket-sharp, Version=1.0.2.59611, Culture=neutral, PublicKeyToken=5660b08a1845a91e, processorArchitecture=MSIL">
<HintPath>..\packages\WebSocketSharp.1.0.3-rc11\lib\websocket-sharp.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="LiveMap.cs" />
<Compile Include="PlayerLocations.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SocketHandler.cs" />
<Compile Include="WebSocketServer.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>COPY /Y "$(TargetPath)" "F:\fx-server\resources\live_map\server"
COPY /Y "$(TargetDir)\deniszykov.WebSocketListener.dll" "F:\fx-server\resources\live_map"
COPY /Y "$(TargetDir)\Newtonsoft.Json.dll" "F:\fx-server\resources\live_map"</PostBuildEvent>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
Expand Down

0 comments on commit fee9958

Please sign in to comment.