Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 215
  • Last Modified:

.NET Remoting Problems!

Let me explain my situation:
I have a Server application (WinForm), it registered some Remote COMs (for example LoginControl(singleton)), LoginControl have a method to authenticate a user called Authenticate(). When a user starts the Client application (WinForm), the client application gets the LoginControl from the Server and then  calls the Authenticate method, assume that it's a valid user, how can I notify the Server application that there was a user logged in?Do I have to write some more remote COM to achieve this?
Thank you!
0
tinh911
Asked:
tinh911
1 Solution
 
PocketMattCommented:
Hi there

well.. there is a way.. i just don't know if this is the correct way for this...
i had the same situation with a web-component.. and well.. there is as far as i know no possibility to get the instance of your singleton object because it is created when someone opens a connection.

now... when i can not get the instance of a class.. why not just use the class itself?

like

public class AuthClass
{
    internal static event EventArgs UserLogin;
    public bool AuthUser(string Username, password)
    {
        bool RetVal;
        // your authentication stuff here assign value to RetVal
        if (RetVal)
        {
            AuthClass.OnUserLogin(this);
        }
        return RetVal;
    }
    private static void OnUserLogin(object sender)
    {
         if (UserLogin != null)
         {
               UserLogin(sender, EventArgs.Empty);
         }
    }
}

in the class just subscribe to the static event of the class and you'll recieve your LogIns

hope this helps
0
 
tinh911Author Commented:
I've tried it! It worked perfectly!
Thank you PocketMatt!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now