Imp.NET icon indicating copy to clipboard operation
Imp.NET copied to clipboard

Error CS0400

Open Shadowblitz16 opened this issue 4 months ago • 1 comments

0>[ImpGenerated]24cfee04c0f84f6fb003c4e7d67598b9.cs(10,121): Error CS0400 : The type or namespace name 'IServer' could not be found in the global namespace (are you missing an assembly reference?)
0>[ImpGenerated]684ab406abdf4ad188ac8b0664868373.cs(10,121): Error CS0400 : The type or namespace name 'IClient' could not be found in the global namespace (are you missing an assembly reference?)
0>------- Finished building project: Mazes. Succeeded: False. Errors: 2. Warnings: 0
using DouglasDwyer.Imp;

namespace Mazes.Engine.Common;

[Shared]
public partial class Client : ImpClient<IServer>
{
    public async Task WriteMessage(string message)
    {
        Console.WriteLine(message);
        await Task.CompletedTask;
    }
    
    private bool _running = true;
    public void Close()
    {
        _running = false;
    }
    public bool IsRunning() => _running;

}
using Arch.Core;
using Arch.System;
using DouglasDwyer.Imp;

namespace Mazes.Engine.Common;


[Shared]
public partial class Server(ushort port) : ImpServer<IClient>(port)
{
    private readonly World _world = World.Create();
    private bool _running = true;
    
    public async Task SendMessage(string message)
    {
        foreach (var client in ConnectedClients)
        {
            await client.WriteMessage(message);
        }
    }

    public void Close()
    {
        _running = false;
    }
    public bool IsRunning() => _running;
    
}
using Mazes.Engine.Common;

public class Program
{
    static async Task Main(string[] args)
    {
        Console.WriteLine("Press S for server, or any other key for client...");
        if (Console.ReadKey(true).Key == ConsoleKey.S)
        {
            var server = new Server(10);
            server.Start();
            while (server.IsRunning())
            {
                Console.ReadKey();
            }
        }
        else
        {
            var client = new Client();
            await client.ConnectAsync("127.0.0.1", 10);

            var server = client.Server;
            while (server.IsRunning())
            {
                var text = Console.ReadLine();
                if (text == null) continue;
        
                await server.SendMessage(text);
                if (text.Contains("exit"))
                    server.Close();
        
            }
        }
    }
}

Shadowblitz16 avatar Sep 01 '25 22:09 Shadowblitz16

Thanks for trying the library out! This library is pretty old, and I'm not actively maintaining it. I would be open to a PR that fixes this problem, though.

DouglasDwyer avatar Sep 02 '25 00:09 DouglasDwyer