forked from altmp/coreclr-module
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Chat.cs
55 lines (44 loc) · 1.47 KB
/
Chat.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using AltV.Net.Elements.Entities;
namespace AltV.Net.Resources.Chat.Api
{
/*internal class Chat : IDisposable
{
private readonly Action<string> broadcast;
private readonly Action<IPlayer, string> send;
private readonly Action<string, Function> registerCmd;
private readonly LinkedList<Function> functions = new LinkedList<Function>();
private readonly LinkedList<GCHandle> handles = new LinkedList<GCHandle>();
public Chat()
{
Alt.Import("chat", "broadcast", out broadcast);
Alt.Import("chat", "send", out send);
Alt.Import("chat", "registerCmd", out registerCmd);
}
public void Broadcast(string message)
{
broadcast?.Invoke(message);
}
public void Send(IPlayer player, string message)
{
send?.Invoke(player, message);
}
public void RegisterCommand(string command, Action<IPlayer, string[]> callback)
{
handles.AddFirst(GCHandle.Alloc(callback));
var function = Function.Create(callback);
functions.AddFirst(function);
registerCmd?.Invoke(command, function);
}
public void Dispose()
{
foreach (var handle in handles)
{
handle.Free();
}
handles.Clear();
}
}*/
}