š”„ā„‘š”‡š”ˆš”‘
š”„ā„‘š”‡š”ˆš”‘
CC#
Created by š”„ā„‘š”‡š”ˆš”‘ on 2/2/2024 in #help
Question
So I have a server in c# and im trying to optomize it in general https://www.quora.com/How-do-I-call-a-C-function-from-C-code So I saw that I can call function wrote in c++ in a c# project so is it worth to rewetie the functions in c++ and call them in c# ? also If i did that running the server in linux will stay the same using dotnet run command or I have to do extra things ? Thanks,
8 replies
CC#
Created by š”„ā„‘š”‡š”ˆš”‘ on 1/16/2024 in #help
Unity question
No description
3 replies
CC#
Created by š”„ā„‘š”‡š”ˆš”‘ on 1/15/2024 in #help
question
Hello, So im trying to make a multiplayer game using unity so what is the best option to render the map Make the client access the database and retreive map values OR client send a request to server side while server access the database and send it back to client note: the map is large its 100 * 60 So I will have to compress it
6 replies
CC#
Created by š”„ā„‘š”‡š”ˆš”‘ on 1/12/2024 in #help
which is faster
so in c# there is something called StringBuilder i just figured it days ago so my question which is is better to use string extra = "Hello " + " World " + " extra stuff"; or to use StringBuilder for same purpose when I searched in Google it says that stringbuilder is much faster so just wanted to ask and make sure.
11 replies
CC#
Created by š”„ā„‘š”‡š”ˆš”‘ on 1/9/2024 in #help
how to check what causes 100% cpu usages ?
I created a server in c# for some reason on my machine it doesn't use 100% of cpu but once I host it on a vps i see that it uses 100%
14 replies
CC#
Created by š”„ā„‘š”‡š”ˆš”‘ on 1/7/2024 in #help
āœ… which is better ?
So I have class Room and Iā€™m trying to do some optomization I created a List of room and then created a function that makes a loop in the list and return the room if it matches the id. Now thinking about it i can also make a Dictionary<int, room> and access room with the id which one is better ?
3 replies
CC#
Created by š”„ā„‘š”‡š”ˆš”‘ on 1/3/2024 in #help
is there is a way to make this faster
No description
14 replies
CC#
Created by š”„ā„‘š”‡š”ˆš”‘ on 12/29/2023 in #help
āœ… Stack overflow.
Im doing a server in c# here is the main
c#
public static void Main(string[] args)
{
while (true)
{
TcpClient Client = Server.AcceptTcpClient();
Thread clientThread = new Thread(new ParameterizedThreadStart(HandleClient));
clientThread.Start(Client);
}
}
c#
public static void Main(string[] args)
{
while (true)
{
TcpClient Client = Server.AcceptTcpClient();
Thread clientThread = new Thread(new ParameterizedThreadStart(HandleClient));
clientThread.Start(Client);
}
}
c#
public static void HandleClient(object Client)
{
TcpClient tcpClient = (TcpClient)Client;


NetworkStream stream = tcpClient.GetStream();

try
{
byte[] buffer = new byte[1024];
int bytesRead;

while ((bytesRead = stream.Read(buffer, 0, buffer.Length)) > 0)
{
string message = Encoding.UTF8.GetString(buffer, 0, bytesRead);

if (message == "")
return;


HandleMessage(message, tcpClient);
}
}
}
c#
public static void HandleClient(object Client)
{
TcpClient tcpClient = (TcpClient)Client;


NetworkStream stream = tcpClient.GetStream();

try
{
byte[] buffer = new byte[1024];
int bytesRead;

while ((bytesRead = stream.Read(buffer, 0, buffer.Length)) > 0)
{
string message = Encoding.UTF8.GetString(buffer, 0, bytesRead);

if (message == "")
return;


HandleMessage(message, tcpClient);
}
}
}
c#
private static void HandleMessage(string message, TcpClient client)
{
// some logic
Console.WriteLine("{DATA IN}: " + message);
HandleJsonMessage(msg, client);
}
c#
private static void HandleMessage(string message, TcpClient client)
{
// some logic
Console.WriteLine("{DATA IN}: " + message);
HandleJsonMessage(msg, client);
}
c#
private static void HandleJsonMessage(string msg, TcpClient client)
{
if (msg == "ready") {
// some logic and check result after 7 seconds
ThreadPool.QueueUserWorkItem(o =>
{
Thread.Sleep(7000);


Packet.sendMsg("%xt%getResult%-1%.", p1.Client);
Packet.sendMsg("%xt%getResult%-1%.", p2.Client);
});
}
}
c#
private static void HandleJsonMessage(string msg, TcpClient client)
{
if (msg == "ready") {
// some logic and check result after 7 seconds
ThreadPool.QueueUserWorkItem(o =>
{
Thread.Sleep(7000);


Packet.sendMsg("%xt%getResult%-1%.", p1.Client);
Packet.sendMsg("%xt%getResult%-1%.", p2.Client);
});
}
}
Ok so the problem is Console.WriteLine("{DATA IN}: " + message); in HandleMessage function is getting spammed and server crashes
8 replies