Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Divij/client message flow #51

Merged
merged 24 commits into from
Jun 9, 2014
Merged

Divij/client message flow #51

merged 24 commits into from
Jun 9, 2014

Conversation

naturalwarren
Copy link
Collaborator

Wiring up application registration with client "init_interview" message.

For the time being we are hardcoding registered applications see line 52, 53 on interview.py. Registration via selection screen to follow.

PEP8 Compliant. Tested notes and heartbeat application.

raise NotImplementedError

def on_join(self, *args, **kwargs):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't onjoin take the sockets as an argument.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a basic method that accepts absolutely anything via *args and **kwargs. Ideally, any application that needs access to the socket can specify its the arguments in its own on_join method.

cls._instantiate_for_interview(interview_id)
cls._apps_instantiated = True

cls._setup_apps(interview_id, client_socket)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setup_apps seems like a strange name for this since it just notifies all apps that someone has joined the interview. I'd probably call it something like notifiy_apps_client_joined or something like that

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's more descriptive. Will do.

_apps_instantiated = False

@classmethod
def initialize(cls, interview_id, client_socket):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we switch this to self from cls?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per conversation with Jesse nope.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cls and self have different meanings in Python. self is used to reference instance variables and cls class variables. When using the @classmethod decorator, the first argument to the method must always be cls and not self

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By the way I'm going to put up a PR today that will get this in. —
Sent from Mailbox

On Sat, Jun 7, 2014 at 5:21 PM, Divij Rajkumar notifications@github.com
wrote:

+from akobi.lib.utils import function_as_callback
+
+
+class Initializer(object):

  • """
  • Initialize the interview for a particular client. Called by the
  • WebSocketHandler's on_message method when it receives an init
  • message from the client (which happens whenever a new client joins)
  • """
  • This class is never going to be instantiated, so having a Borg here

  • isn't going to work. Instead just use a class variable

  • _apps_instantiated = False
  • @classmethod
  • def initialize(cls, interview_id, client_socket):
    cls and self have different meanings in Python. self is used to reference instance variables and cls class variables. When using the @classmethod decorator, the first argument to the method must always be cls and not self

Reply to this email directly or view it on GitHub:
https://github.com/jivid/akobi/pull/51/files#r13521501

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Get what in?

@jbrick
Copy link
Collaborator

jbrick commented Jun 6, 2014

shaep it

@sdosborn
Copy link
Collaborator

sdosborn commented Jun 6, 2014

Lick it

@s28jain
Copy link
Collaborator

s28jain commented Jun 6, 2014

shipwrecked!

@naturalwarren
Copy link
Collaborator Author

Not quiet ready. Working on a non type error that's appeared.

@naturalwarren
Copy link
Collaborator Author

Ship it!

# everytime a client connects, we move this logic into the registry
# so the initializer can be left stateless
if self.interviews[interview_id][app_name] is not None:
log.info("%s has already been instantiated for %s" % (app_name,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably don't need this log, definately not at an info level.

@jbrick
Copy link
Collaborator

jbrick commented Jun 9, 2014

fix n ship

jivid added a commit that referenced this pull request Jun 9, 2014
@jivid jivid merged commit 7d61251 into develop Jun 9, 2014
@jivid jivid deleted the divij/client_message_flow branch June 14, 2014 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants