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

  • Home
  • SEARCH
  • 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 8671293
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:54:55+00:00 2026-06-12T18:54:55+00:00

I’m working on a homework assignment, modifying code created by my professor. Unfortunately, he’s

  • 0

I’m working on a homework assignment, modifying code created by my professor. Unfortunately, he’s not available to me currently so I’m reaching out to the stackoverflow crowd.

This snippet is from a file “Peer.scala”, which communicates with an actor from another class “RemoteActorChat.scala”. I have only included the snippet that I believe is the cause of my issue, for the sake of brevity. Should the rest of the code be useful in finding a solution, I’ll gladly post it.

My intent is to have the Peer capture input from the console in a continuous loop, while simultaneously reacting to any messages received from the RemoteChatActor.

…

def act {
...
loop {
  val textInput = Console.readLine(name + ">").toString()
  textInput match {
    case "Unsubscribe" =>
      unsubscribe

    case "Subscribe" =>
      subscribe(name))

    case "?" =>
      println("Type any message to send it to the chatroom")
      println("Type 'Unsubscribe' (without quotes) to leave the chatroom")
      println("Type 'Subscribe' (without quotes) to re-join the chatroom")

    case _ =>
      post(textInput)
  }

  react {
    case Post(msg) =>
      println(name + " got a post = " + msg)
  }
}

}

…

When the inputText is matched to _ the post function is called, does it’s thing and I get another prompt. I can post messages all day long like this if I want.

However, when inputText is matched to “Unsubscribe”, “Subscribe”, or “?”, the behavior is different. The statements in the case are executed IE) the unsubscribe or subscribe functions are called and do their thing as expected. However, I don’t get the prompt back to continue sending input from the console. The peer basically just hangs at this point. I expect another prompt but the console window is just empty and doesn’t take any additional input.

Clearly my understanding of how this should work is flawed.
What am I misunderstanding, and how can I make this do what I intend?

  • 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-12T18:54:56+00:00Added an answer on June 12, 2026 at 6:54 pm

    The actor is waiting for a Post inside react. It won’t continue until it gets one. Since you only send one in one case, only that case gets through.

    If you want to make the other cases work, either have them also send a message that the react block can receive (at least as a case _ inside the react block), or move the react block so it will only be entered if there will in fact be a Post coming back its way at some point.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I know there's a lot of other questions out there that deal with this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am currently running into a problem where an element is coming back from
I need a function that will clean a strings' special characters. I do NOT

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.