GithubHelp home page GithubHelp logo

starling-chat-console's Introduction

starling-chat-console

A chat console for starling

A starling/feathers based chat console that can be integrated within a mobile application (AIR) and Facebook (Flash), developed in pure actionscript.

The below isn't implemented, it's only a specification.

Usage

  1. Clone the repo.
  2. Add the repo's src/ folder to your project's source-path.
  3. Implement your own ChatServer.
  4. Instanciate the ChatConsole and add it to your scene.

User Interface

User Interface

Chat console appears from the right hand side. it's possible to either slide it to the right, close it by clicking "close" or by clicking outside the chat console.

Game is still visible on the left hand side. The total width of the visible size may vary, depending on the device size (tablet or phone). However, the chat console should capture events made on the game part when it's visible. When the user clicks on the outside of the console, the console hides itself.

Initial API

package fovea.chat;

public class ChatMessage {

  // user that sent this message
  public var username:String;

  // URL of the avatar image (always a square)
  public var avatarURL:String;

  // message text
  public var message:String;

  // current state of the message (see const below)
  public var state:int;

  public static const STATE_IN_PROGRESS:int = 0;
  public static const STATE_SUCESS:int = 1;
  public static const STATE_FAILED:int = 2;
}

public interface IChatServer {

  // initiate sending a message
  function send(message:String):void;

  // return the list of messages on the chat room
  function getData():Vector<ChatMessage>;

  // listeners functions will be called without arguments
  // when data is updated.
  function addListener(f:Function):void;
  function removeListener(f:Function):void;
}

// The IChatTheme interface allow to define your own theme for the ChatConsole.
// It's a collection of factory methods for each basic elements it uses.
// (to be defined while implementing the ChatConsole)
public interface IChatTheme {

  // example call 1
  function createTextField(prompt:String):TextField;

  // example call 2
  function getBackgroundColor():uint;

  // ...
}

public class ChatConsole extends Sprite {

  public function ChatConsole(server:IChatServer, theme:IChatTheme);

  // make the console appear on screen (animated from right)
  public function show():void;

  // make the console disappear from screen (animated to the right)
  public function hide():void;
}

System Messages

The chat console can also display system message. Such messages will have a empty username and should have a special presentation (see screenshot on top).

starling-chat-console's People

Contributors

j3k0 avatar justinwalkerthotkraft avatar

Stargazers

Enclavia Labs avatar Roman Murashov avatar  avatar

Watchers

 avatar James Cloos avatar Enclavia Labs avatar Souad El Merhebi avatar  avatar  avatar

starling-chat-console's Issues

Demo the "in-progress" and "failed" message state

To demo the "in-progress" and "failed" message state, dummy server could add new messages as "in-progress" and set them "success" (or sometimes "failed") after 2 seconds.

in-progress should show some kind of loading indicator (a rotating stuff)

failed should show a failure indicator (a red "x" for instance)

Localization

Allow to inject a translate function into the module.

(not to translate user messages, but UI elements)

Shadow

Would it be possible to add a little shadow on the left of the chat area?

Could be easily made programmatically, using:

  • 1px wide quad, 0.1 opacity (or whatever is nice)
  • 2px wide quad, 0.1 opacity
  • 3px wide quad, 0.1 opacity

That would be enough to create a smooth 3px wide shadow.

Stack overflow with very long text

Could it be a starling limitation (?).

Whatever the reason, and if there ain't better fix: a simple one could be to trim the texts to a given reasonable MAX_LENGTH (say 1024)... If trimmed, "..." (three dots) should be added.

When pasting a long text like:

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus hendrerit. Pellentesque aliquet nibh nec urna. In nisi neque, aliquet vel, dapibus id, mattis vel, nisi. Sed pretium, ligula sollicitudin laoreet viverra, tortor libero sodales leo, eget blandit nunc tortor eu nibh. Nullam mollis. Ut justo. Suspendisse potenti.

Sed egestas, ante et vulputate volutpat, eros pede semper est, vitae luctus metus libero eu augue. Morbi purus libero, faucibus adipiscing, commodo quis, gravida id, est. Sed lectus. Praesent elementum hendrerit tortor. Sed semper lorem at felis. Vestibulum volutpat, lacus a ultrices sagittis, mi neque euismod dui, eu pulvinar nunc sapien ornare nisl. Phasellus pede arcu, dapibus eu, fermentum et, dapibus sed, urna.

Following exception occurs:

Error: Error #1023: Stack overflow occurred.
    at starling.events::EventDispatcher/invokeEvent()
    at starling.events::EventDispatcher/dispatchEvent()
    at starling.display::DisplayObject/dispatchEvent()
    at starling.events::EventDispatcher/dispatchEventWith()
    at feathers.controls::TextInput/set text()
    at fovea.chat.reply_window::ReplyWindowDisplay/onTextChanged()
    at starling.events::EventDispatcher/invokeEvent()
    at starling.events::EventDispatcher/dispatchEvent()
    at starling.display::DisplayObject/dispatchEvent()
    at starling.events::EventDispatcher/dispatchEventWith()
    at feathers.controls::TextInput/set text()
    at fovea.chat.reply_window::ReplyWindowDisplay/onTextChanged()
    at starling.events::EventDispatcher/invokeEvent()
    at starling.events::EventDispatcher/dispatchEvent()
    at starling.display::DisplayObject/dispatchEvent()
    at starling.events::EventDispatcher/dispatchEventWith()
    at feathers.controls::TextInput/set text()
    at fovea.chat.reply_window::ReplyWindowDisplay/onTextChanged()
    at starling.events::EventDispatcher/invokeEvent()
    at starling.events::EventDispatcher/dispatchEvent()
    at starling.display::DisplayObject/dispatchEvent()
    at starling.events::EventDispatcher/dispatchEventWith()
    at feathers.controls::TextInput/set text()
    at fovea.chat.reply_window::ReplyWindowDisplay/onTextChanged()
    at starling.events::EventDispatcher/invokeEvent()
    at starling.events::EventDispatcher/dispatchEvent()
    at starling.display::DisplayObject/dispatchEvent()
    at starling.events::EventDispatcher/dispatchEventWith()
    at feathers.controls::TextInput/set text()
    at fovea.chat.reply_window::ReplyWindowDisplay/onTextChanged()
    at starling.events::EventDispatcher/invokeEvent()
    at starling.events::EventDispatcher/dispatchEvent()
    at starling.display::DisplayObject/dispatchEvent()
    at starling.events::EventDispatcher/dispatchEventWith()
    at feathers.controls::TextInput/set text()
    at fovea.chat.reply_window::ReplyWindowDisplay/onTextChanged()
    at starling.events::EventDispatcher/invokeEvent()
    at starling.events::EventDispatcher/dispatchEvent()
    at starling.display::DisplayObject/dispatchEvent()
    at starling.events::EventDispatcher/dispatchEventWith()
    at feathers.controls::TextInput/set text()
    at fovea.chat.reply_window::ReplyWindowDisplay/onTextChanged()
    at starling.events::EventDispatcher/invokeEvent()
    at starling.events::EventDispatcher/dispatchEvent()
    at starling.display::DisplayObject/dispatchEvent()
    at starling.events::EventDispatcher/dispatchEventWith()
    at feathers.controls::TextInput/set text()
    at fovea.chat.reply_window::ReplyWindowDisplay/onTextChanged()
    at starling.events::EventDispatcher/invokeEvent()
    at starling.events::EventDispatcher/dispatchEvent()
    at starling.display::DisplayObject/dispatchEvent()
    at starling.events::EventDispatcher/dispatchEventWith()
    at feathers.controls::TextInput/set text()
    at fovea.chat.reply_window::ReplyWindowDisplay/onTextChanged()
    at starling.events::EventDispatcher/invokeEvent()
    at starling.events::EventDispatcher/dispatchEvent()
    at starling.display::DisplayObject/dispatchEvent()
    at starling.events::EventDispatcher/dispatchEventWith()
    at feathers.controls::TextInput/set text()
    at fovea.chat.reply_window::ReplyWindowDisplay/onTextChanged()
    at starling.events::EventDispatcher/invokeEvent()
    at starling.events::EventDispatcher/dispatchEvent()
    at starling.display::DisplayObject/dispatchEvent()
    at starling.events::EventDispatcher/dispatchEventWith()

Another stacktrace one can get while writing a very very long text:

ArgumentError: Error #3683: Texture too big (max is 2048x2048).
    at flash.display3D::Context3D/createTexture()
    at starling.textures::Texture$/empty()
    at starling.textures::Texture$/fromBitmapData()
    at starling.text::TextField/createRenderedContents()
    at starling.text::TextField/redraw()
    at starling.text::TextField/getBounds()
    at starling.display::DisplayObjectContainer/getBounds()
    at starling.display::DisplayObject/get width()
    at fovea.chat.message::UserMessageDisplay/layout()
    at fovea.chat.message::ChatMessage/layout()
    at fovea.chat::ChatConsole/layout()
    at fovea.chat::ChatConsole/addMessage()
    at fovea.chat::ChatConsole/addMessageData()
    at fovea.chat.app::TestHarness/onMessageSent()
    at starling.events::EventDispatcher/invokeEvent()
    at starling.events::EventDispatcher/dispatchEvent()
    at starling.events::EventDispatcher/dispatchEventWith()
    at fovea.chat.app.test_data::Server/send()
    at fovea.chat::ChatConsole/onSendReplyText()
    at starling.events::EventDispatcher/invokeEvent()
    at starling.events::EventDispatcher/bubbleEvent()
    at starling.events::EventDispatcher/dispatchEvent()
    at starling.display::DisplayObject/dispatchEvent()
    at starling.events::EventDispatcher/dispatchEventWith()
    at fovea.chat.reply_window::ReplyWindowDisplay/sendText()
    at fovea.chat.reply_window::ReplyWindowDisplay/onTextChanged()
    at starling.events::EventDispatcher/invokeEvent()
    at starling.events::EventDispatcher/dispatchEvent()
    at starling.display::DisplayObject/dispatchEvent()
    at starling.events::EventDispatcher/dispatchEventWith()
    at feathers.controls::TextInput/set text()
    at feathers.controls::TextInput/textEditor_changeHandler()
    at starling.events::EventDispatcher/invokeEvent()
    at starling.events::EventDispatcher/dispatchEvent()
    at starling.display::DisplayObject/dispatchEvent()
    at starling.events::EventDispatcher/dispatchEventWith()
    at feathers.controls.text::StageTextTextEditor/set text()
    at feathers.controls.text::StageTextTextEditor/stageText_changeHandler()
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at Function/<anonymous>()

The one above is "worst" in the sense that the exception will occur at every frame making the app almost irresponsive. I believe both be solved using the same MAX_LENGTH protection.

Not possible to compile

Not possible to compile because not of all files are available in repo, for exapmple I was not able to find

import fovea.utils.NativeController;
import fovea.ui.InputViewportScroller;

Can't compile test application

Seems like AppTestHarness is missing in the git repo.

verity:starling-chat-console jeko$ amxmlc -library-path=lib/starling.swc src/fovea/chat/app/App.as
Loading configuration: /.../flex/frameworks/air-config.xml

/.../starling-chat-console/src/fovea/chat/app/App.as:21
Error: Access of possibly undefined property AppTestHarness.
            _starling = new Starling(AppTestHarness, stage, viewPort);
                                     ^

Very long text do not word wrap and layout correctly

Tested with ThemeWeb.

Using the below text:

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Here's the result on screen:
screen shot 2015-10-26 at 22 12 44

Provide a DefaultChatTheme

ThemeWeb and ThemeMobile don't have to be such repetitions of each other.

Provide a default theme class with sensible defaults, that can be extended. This class can be part of the public API of the module.

package fovea.chat.interfaces {
public class DefaultChatTheme implements IChatTheme { ... all defaults functions ... }
}

package fovea.chat.app.test_data {
public class ThemeWeb extends DefaultChatTheme { ... only the specific ... }
}

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.