Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9011221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T02:40:22+00:00 2026-06-16T02:40:22+00:00

I have a class ChatManager , which has a ChatServer and a ChatClient (WCF)

  • 0

I have a class ChatManager, which has a ChatServer and a ChatClient(WCF) class inside of them.

I want my controller which instantiates the ChatManager to be able to subscribe to the UserConnected, UserDisconnected and MessageReceived events that are on the ChatClient.

What is the most elegant and logical way to do this? Is it silly for me to define the events in the ChatClient like I have, and then redefine the events in the ChatManager solely to pass the events up to the Controller without it having to deal with or know about the ChatClient? The ChatManager would subscribe to the events of the ChatClient, and then fire off its own events which the ChatController would be listening to.

I know WPF has the concept of bubbling up of events, but I don’t know if that is for this type of scenario, since nothing is part of a user interface.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T02:40:23+00:00Added an answer on June 16, 2026 at 2:40 am

    I’d start by questioning whether both ChatManager and ChatController can both justify their own existence. Generally whenever you find yourself creating a “Manager” class, it really isn’t necessary, especially if part of what it is doing consists of merely relaying messages.

    Controller classes can struggle against SRP since their “responsibility” is quite broad. In cases where you want to delegate responsibility for certain behaviour then leave the responsibility for the ChatClient with the controller, and initialize a subordinate controller with the ChatClient (through a contract interface) so that it can interact with the client as needed. Just make sure that when you start registering for events that you de-register those events before discarding subordinates or the client, otherwise you’ll be looking at managed memory leaks.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have class A which has ISerializable implemented for custom serialization. Now i need
I have Class which extends JDialog . Have an another JDialog declared inside the
I have class which has Map, but when I try to presist this entity,
I have Class and Student objects. Both have collection of another as property. Which
I have class LegacyClass which inherits OldBaseClass. I'm considering a change to introduce a
We have class lua. In lua class there is a method registerFunc() which is
I have class like this below shown. which contains the shopping items where the
I have class MyContainer < ActiveRecord::Base :has_many MyObjects, :dependent => :destroy end I want
I have class Lazy which lazily evaluates an expression: public sealed class Lazy<T> {
i have class call example1 this class defines a background, and i want to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.