⚡ My Dev Statistics
fabianterhorst / coreclr-module Goto Github PK
View Code? Open in Web Editor NEWOld alt:V CoreClr (.NET Core Common Language Runtime) community made module. New: https://github.com/altmp/coreclr-module
License: MIT License
Old alt:V CoreClr (.NET Core Common Language Runtime) community made module. New: https://github.com/altmp/coreclr-module
License: MIT License
There is currently a regression bug in the AltV.Net.Host
implementation, that can lead to the following exception:
InvalidOperationException:
AssemblyLoadContext is unloading or was already unloaded.
As it turns out, the Host
class only holds a weak reference to the load context in its static dictionary and no other objects are holding any references on it.
coreclr-module/api/AltV.Net.Host/Host.cs
Lines 100 to 103 in f97394f
Therefore, the load context is eligible for garbage collection at any time!
This is exactly what happens in our case, when we load larger libraries with lots of dependencies in our ServerResource.OnStart()
method.
It happens at different points in time, with different assemblies, but GC is always triggert at some point in the start process and an exception is thrown on the next try to load an assembly into the already finalized load context.
This is a regression. It should work on the master branch, because it does not use a WeakReference
there.
I will provide a PR, that fixes this issue and should not leak any memory either.
This was reported to our repo as a possible .NET Core 3.0 incompatibility of our database provider, but turned out to be unrelated to that (PomeloFoundation/Pomelo.EntityFrameworkCore.MySql#825).
/cc @lsvMoretti
Client:
alt.emitServer("test","somestring",new alt.Vector3(1,2,3);
Server:
[ClientEvent("test")]
public void myCoolFun(IPlayer player, params object[] args)
{ // args[1] is object[3] { "x":1, "y":2,"z";3 } looks like "dynamic"
var pos = (Position)Convert.ChangeType(typeof(Position),args[1]);
}
will fail because Position does not implement IConvertible.
Yes one could cast it, by IConvertible is the cleaner solution.
Even Better: get rid off Rotation/Position type and use Vector3 ;)
Document https://github.com/FabianTerhorst/coreclr-module/blob/master/api/AltV.Net/Elements/Entities/IColShape.cs code, same as already done in https://github.com/FabianTerhorst/coreclr-module/blob/master/api/AltV.Net/Elements/Entities/IPlayer.cs or https://github.com/FabianTerhorst/coreclr-module/blob/master/api/AltV.Net/Elements/Entities/IVehicle.cs
Filepath needs to be docs/articles/colshapes-example.md
Should contain understandable description about how to create colshapes, what there should be used for and how the events are working.
Document https://github.com/FabianTerhorst/coreclr-module/blob/master/api/AltV.Net/Elements/Entities/IBlip.cs code, same as already done in https://github.com/FabianTerhorst/coreclr-module/blob/master/api/AltV.Net/Elements/Entities/IPlayer.cs or https://github.com/FabianTerhorst/coreclr-module/blob/master/api/AltV.Net/Elements/Entities/IVehicle.cs
Currently if ou pass short or ushort values to EmitLocked you get an error in logs : "can't convert type:System.Int16" or "can't convert type:System.UInt16"
This will avoid casting all short/ushort send with EmitLocked() to int
When you send a float/double from clientside using alt.emitServer("eventName", 0.2)
everything is as expected, you get float/double on serverside event handler. But when you send it using alt.emitserver("eventName", 2)
you get 0 on your float/double value.
Steps to reproduce:
Here is a showcase of the problem on a screenshot, with or without parseFloat problem still occurs
Branch: rc
Build: #1300
Create documentation for LLDB Debugging.
sudo apt install lldb
dotnet tool install -g dotnet-sos
dotnet sos install
lldb
setclrpath /usr/share/dotnet/shared/Microsoft.NETCore.App/3.1.3
quit
dotnet sos install
lldb
process attach -p <PID>
continue // enter it each time when it reached a breakpoint
clrstack // to get native stacktrace
Add optional networking entity module that synchronizes the entities and the shared data with the clients. This will make it possible to create objects, peds and markers from serverside.
The server will send the entities via a tcp socket or probably websockets and protobuf serialization to the clients. Can't use udp socket because cef doesn't support it. The entities will support serverside and synchronized meta data. The entity types will be generic on serverside and the client will have to decide how to render them when entering / exiting streaming range.
Client/server version
Build #1299 (RC)
AltV.Net.Async (1.40.1-rc)
AltV.Net.Interactions (1.1.0-dev-preview)
Current behavior
The interaction is not working in all dimensions if created with Dimension.GlobalDimension
Expected behavior
Global dimension should trigger regardless of player dimension like entity sync
Steps to reproduce
new Interaction(0, 0, new Vector3(0, 0, 72), Dimension.GlobalDimension, 10);
var ia0 = await AltInteractions.FindInteractions(new Position(0, 0, 72), 0);
var ia1 = await AltInteractions.FindInteractions(new Position(0, 0, 72), Dimension.GlobalDimension);
Console.WriteLine($"Interactions dimension 0: {ia0.Length}"); // <-- 0
Console.WriteLine($"Interactions global: {ia1.Length}"); // <-- 1
Add support for specifying .csproj files instead of dll's. The host will compile the project on resource start.
When I try to reload any resource after I made changes to it, the server crashes sometimes with the following messages:
Received an unhandled exception from : System.BadImageFormatException: [*.dll] Illegal or unimplemented ELEM_TYPE in signature.
at \].nary`2.Current
at AltV.Net.ModuleWrapper.OnStop()
Received an unhandled exception from : System.BadImageFormatException: Bad IL range.
at t^D.l.nvokeMember
at AltV.Net.ModuleWrapper.OnStop()
OnStop contains the following code:
public override void OnStop()
{
Alt.Log("OnStop");
}
OP Specs:
Distributor ID: Debian
Description: Debian GNU/Linux 10 (buster)
Release: 10
Codename: buster
Create a ExplosionType.cs in https://github.com/FabianTerhorst/coreclr-module/tree/master/api/AltV.Net/Enums folder
Declare a enum named ExplosionType inside it
Use following values: https://pastebin.com/JTV9T1f3
Use good formatted names for the enum values. E.g. From EXP_TAG_DONTCARE
=> DontCare
Hello is there a reason for the drawable to be a ushort as i would have to use -1 to remove clothes or is there a other way i didn´t see
Kind regards Martin
Async event called! 0
or sync for sync eventAsync event called! 0
being printedWhen trying to construct class again, two instances of class receive events, and this results in code not working properly
using System;
using System.Threading.Tasks;
using AltV.Net;
using AltV.Net.Async;
public class TestEvents
{
public static int InstanceNumber = 0;
private int _instanceNumber;
private TestEvents()
{
this._instanceNumber = TestEvents.InstanceNumber;
TestEvents.InstanceNumber++;
AltAsync.OnClient<AltCorePlayer, int>("testEventJob:asyncEvent", this.AsyncEvent);
Alt.OnClient<AltCorePlayer, int>("testEventJob:event", this.Event);
}
private async void AsyncEvent(AltCorePlayer player, int n)
{
Console.WriteLine($"Async event called! {this._instanceNumber}");
}
private void Event(AltCorePlayer player, int n)
{
Console.WriteLine($"Sync event called! {this._instanceNumber}");
}
public void Finish()
{
AltAsync.OffClient<AltCorePlayer, int>("testEventJob:asyncEvent", this.AsyncEvent);
Alt.OffClient<AltCorePlayer, int>("testEventJob:event", this.Event);
}
}
}
Example:
player.SetPosition(466f, -635f, 28f);
or
player.Position = new Position(466f, -635f, 28f);
player.Position
doesn't refresh, the old remains.
Same thing on GetPosition()
I'm use SimpleInjector and I except to register instance when OnStart run.
But unfortunately the IScript's constructor run before.
Filepath needs to be docs/articles/networking-entity.md
Should contain understandable description about how to setup networking entity, how to create networking entites, what there should be used for and how client and serverside streaming is working.
This returns "true" when called from another resource:
private bool Test(int integer)
{
return true;
}
Alt.Export("test", new Func<int, bool>(Test));
This returns "false" when called from another resource:
private bool Test(IPlayer player)
{
return true;
}
Alt.Export("test", new Func<IPlayer, bool>(Test));
The module should be used to communicate between chat resource and c# resource.
It should be published to nuget via github actions, because travis build tasks max parallel count is reached.
Requires #64
Another nice update would be to have a Color Strcut, here I have an example:
`
public struct Color
{
public int Red;
public int Green;
public int Blue;
public int Alpha;
public Color(int number);
public Color(int r, int g, int b);
public Color(int r, int g, int b, int a);
public int ToInt32();
}
`
Document https://github.com/FabianTerhorst/coreclr-module/blob/master/api/AltV.Net/Elements/Entities/ICheckpoint.cs code, same as already done in https://github.com/FabianTerhorst/coreclr-module/blob/master/api/AltV.Net/Elements/Entities/IPlayer.cs or https://github.com/FabianTerhorst/coreclr-module/blob/master/api/AltV.Net/Elements/Entities/IVehicle.cs
The usage of both Vehicle.Remove and Alt.RemoveVehicle seem to crash my server. I'm kind of lost and I've tried it in multiple different scenarios and still crashes. I'm not too sure if I'm doing something wrong, but figured I'd report just in case it were an issue.
The code I'm using is really simple, at first I check if the player is in any vehicle and if they are in the drivers seat. If they match these conditions, that's fine then we remove the vehicle using either;
player.Vehicle.Remove();
or
Alt.RemoveVehicle(player.Vehicle)
Even under a try - catch, weirdly it does not provide any details as to what the cause of the error is.
I would appreciate adding a degree side rotation attribute for entitys as well, since a lot of rotation based methods use 180° rotation (e.g. player rotation or camera rotation) and the current attribute gives back radiant which has to be converted first
When using AltEntitySync.Init i can't set the sync rate as described in multiple documentations/examples.
What i am trying to do:
AltEntitySync.Init(1, 100, (threadId) => false,
(threadCount, repository) => new ServerEventNetworkLayer(threadCount, repository),
(entity, threadCount) => (entity.Id % threadCount),
(entityId, entityType, threadCount) => (entityId % threadCount),
(threadId) => new LimitedGrid3(50_000, 50_000, 100, 10_000, 10_000, 300),
new IdProvider());
Documentation/examples i used:
http://csharp.altv.mp/articles/entity-sync.html
https://github.com/DasNiels/altv-object-streamer/
https://github.com/LameuleFR/altv-csharp-streamer
It would be nice to have a Alt.CreateTextLabel function.
Here are some parameters:
Alt.CreateTextLabel(string text, Position pos, float range, float size, int font, Color color, bool entitySeethrough = false, uint dimension = uint.MaxValue)
I will make another post for the Color struct. #
Add the networking entity as own nodejs task to travis build.
Publish it as attachment in github relase section.
Publish it as npm package.
Add support for
The callbacks are getting triggered from a different thread.
A collision shape will be a world object that supports server side data and custom object factories.
Use nethost for best practice loading of the hostfxr path depending on runtime config folder.
Currently there is option to get all players synchronously Alt.GetAllPlayers()
but there is no method to get them asynchronously like AltAsync.GetAllPlayers()
.
There are currently 2 overloads taking VehicleModel
and model as uint, third overload for model as a string would be good. AltAsync.CreateVehicle(string model, Position pos, float heading)
This will be the first optional c# resource that should build via github actions. It should build a zip that contains resource.cfg, server and clientside files.
Note
This is a carry-over from altmp/altv-issues#707.
Client/server version
Build #1301, branch release
Current behavior
When using the HostBuilder
and a HostedService
the server stop gets stuck. Consider the following code:
namespace Test
{
public class Program : Resource
{
private IHost _host;
public Program()
=> _host = CreateHostBuilder()
.Build();
public static IHostBuilder CreateHostBuilder()
=> Host.CreateDefaultBuilder()
.ConfigureHostConfiguration((builder) => {
builder
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json", optional: true)
.AddUserSecrets<Core>();
})
.ConfigureLogging((context, builder) => {
builder
.AddConfiguration(context.Configuration)
.AddSentry();
})
.ConfigureServices(ConfigureServices)
.UseConsoleLifetime();
public async static void ConfigureServices(HostBuilderContext context, IServiceCollection collection)
{
[...]
// Add Core
collection.AddHostedService<Core>();
}
public async override void OnStart()
{
await _host.StartAsync();
}
public async override void OnStop()
{
await _host.StopAsync();
}
}
public class Core : IHostedService
{
public async Task StartAsync(CancellationToken cancellationToken)
{
Console.WriteLine("Start");
}
public async Task StopAsync(CancellationToken cancellationToken)
{
Console.WriteLine("Stop");
}
}
}
Produces the following output:
[21:55:03] alt:V Server, build #1301, branch release
[21:55:03] Starting alt:V Server on 0.0.0.0:7788
[21:55:03] coreclr-module: version found: 3.1.9
[21:55:03] coreclr-module: greatest version: 3.1.9
[21:55:04] Loading resource test
Start
info: Microsoft.Hosting.Lifetime[0]
Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
Hosting environment: Production
info: Microsoft.Hosting.Lifetime[0]
Content root path: /opt/altv
[21:55:04] Loaded resource test
[21:55:04] Starting HTTP server on 0.0.0.0:7788
[21:55:04] Console thread started (ThreadId: 8)
[21:55:04] Main thread started (ThreadId: 6)
[21:55:04] VoicePacketProcess thread started (ThreadId: 9)
[21:55:04] VoiceStreamer thread started (ThreadId: 10)
[21:55:04] Colshape thread started (ThreadId: 11)
[21:55:04] EntityStreamer thread started (ThreadId: 36)
[21:55:04] Network thread started (ThreadId: 38)
[21:55:04] Server started
^Cinfo: Microsoft.Hosting.Lifetime[0]
Application is shutting down...
Context (environment)
Currently only tested within a Docker Container, but this should not really matter.
Add serverside streaming.
Remove networking entity factory and allow adding own super classes.
The current entity sync init is complex to understand and doesnt support multiple independent instances which makes it almost impossible to use inside libraries.
This api would also allow to provide a network layer per type to fine gain data diffing and serialization for best possible performance.
API proposal:
var entitySync = new EntitySync.Builder()
.type(number, thread Index (by default type number), space partitioning algorithm, network layer)
.build();
Document https://github.com/FabianTerhorst/coreclr-module/blob/master/api/AltV.Net/Elements/Entities/IVoiceChannel.cs code, same as already done in https://github.com/FabianTerhorst/coreclr-module/blob/master/api/AltV.Net/Elements/Entities/IPlayer.cs or https://github.com/FabianTerhorst/coreclr-module/blob/master/api/AltV.Net/Elements/Entities/IVehicle.cs
Dimensions are very important argument for example for markers or blips, if you want to create some marker only for one interior. If you could add dimensions to Networking Entity, would be awesome.
Add Position overload for double which converts x, y, z to float in background.
Im in C# Lib and can't use Console.XXX to set my colors vor other stuff. I would like to do this with Alt.Server.Console.X
Example:
Alt.Server.Console.Forecolor()
Alt.Server.Console.Backcolor()
Alt.Server.Console.Reset() //default values
When a Client disconnects (via 'reconnect' atm), the Server will throw an error, wether you destroy the networking Entity on ClientSide or not.
System.ObjectDisposedException: The CancellationTokenSource has been disposed. at System.Threading.CancellationTokenSource.ThrowObjectDisposedException() at net.vieapps.Components.WebSockets.WebSocketImplementation.Close() at net.vieapps.Components.WebSockets.WebSocket.CloseWebsocketAsync(ManagedWebSocket websocket, WebSocketCloseStatus closeStatus, String closeStatusDescription) at AltV.Net.NetworkingEntity.Elements.Providers.AuthenticationProvider.<>c__DisplayClass8_0.<<-ctor>b__0>d.MoveNext()
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.