Code Monkey home page Code Monkey logo

alibaba-code-challenge's Introduction

Alibaba code challenge

Write a component that can send a string message asynchronously and receive a response to and from a server.

What should be implemented

The server should be able to respond to the following messages:

  • Request: "Hello" Response: "Hi" after a one second delay.
  • Request: "Bye" Response: "Bye" The server closes the client connection.
  • Request: "Ping" Response "Pong"
  • Any other message should be considered invalid and an exception should be raised on the client.

The client and server must maintain an active connection

The underlying protocol is of your choice as long as a single stable network connection is used.

The implementation should be thread safe

Simultaneous send operations should be completed successfully.

Interface

The client should implement the following interface:

interface IClient
{
    Task<string> SendAsync(string message);
}

Bonus implementation 1

Client requests should be sent down the wire as soon as possible, this means a previous request shouldn't block the client from sending new ones to the server. The server then processes the requests and sends back the response.

Bonus implementation 2

Implement the following interface instead of the basic one:

interface IClient
{
    Task<IResponseMessage> SendAsync(IRequestMessage requestMessage);
    Task<TResponseMessage> SendAsync<TResponseMessage>(IRequestMessage requestMessage) where TResponseMessage: IResponseMessage;
}

alibaba-code-challenge's People

Contributors

odises avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.