Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

basic read and right to the irc connection

  • Loading branch information...
commit f43ffa56fad4595225b1ca3c3c340211937b812e 1 parent bf45d37
@beaucollins authored
View
2  chatty.application/connections/depends.js
@@ -1,5 +1,5 @@
enyo.depends(
+ "source/ChatClient.js",
"source/ConnectionManager.js",
- "source/IRCClient.js",
"css/style.css"
);
View
1  chatty.application/connections/mock/connectionManager_irc_client_connect.json
@@ -0,0 +1 @@
+{"clientId":1,"status":"connect"}
View
17 ...plication/connections/source/IRCClient.js → ...lication/connections/source/ChatClient.js
@@ -1,5 +1,6 @@
enyo.kind({
- name:"IRCClient",
+ name:"ChatClient",
+ kind:'Component',
published: {
host:'irc.freenode.net',
port:6667,
@@ -28,23 +29,27 @@ enyo.kind({
host:this.host,
port:this.port
});
- }
+ },
failed:function(service, response, request){
this.doFailure(response, request);
},
receivedData:function(service, response, request){
if (response.status == 'connect') {
- this.clientId = response.client_id;
+ this.clientId = response.clientId;
this.doConnect();
- this.write("NICK " + this.nick + "\r\n" + "USER " + this.nick + " 0 * " + this.name);
- };
+ this.write("NICK " + this.nick + "\r\n" + "USER " + this.nick + " 0 * " + this.name + "\r\n");
+ }else if (response.status == 'read') {
+ this.doMessageReceived(response.data);
+ }else if (response.status == 'close'){
+ this.doClose();
+ }
},
sentMessage:function(service, response, request){
this.doMessageSent(response.message);
},
write:function(data){
this.$.message.call({
- client
+ clientId:this.clientId,
message:data
});
}
View
37 chatty.application/connections/source/ConnectionManager.js
@@ -2,6 +2,7 @@ enyo.kind({
name:'ConnectionManager',
kind:'VFlexBox',
components:[
+ {name:'irc_client', kind:'ChatClient', onMessageSent:'messageSent', onMessageReceived:'messageReceived', onConnect:'connected'},
{kind:'HFlexBox', flex:1, components:[
{ kind:'VFlexBox', flex:1, components:[
{kind:'Header', content:'Config'},
@@ -19,24 +20,18 @@ enyo.kind({
{ kind:'Scroller', flex:1, components:[
{ name:'log', className:'log', allowHtml:true}
]},
- { kind:'Toolbar', components:[
- { caption:"Join Room" }
+ { name:'composer', kind:"HFlexBox", components:[
+ { name:"messageInput", kind: 'Input', flex:1, oninput:'checkMessage', onkeypress:'sendOnEnter' },
+ { name:'sendButton', kind: 'Button', caption:'Send', onclick:"sendMessage", disabled:true }
] }
]}
]}
],
connect: function(sender){
- this.appendLog("<p>Connecting ...</p>");
- this.createComponent({
- name:'irc_client',
- kind:'IRCClient',
- host:this.$.host.value,
- port:this.$.port.value,
- nick:this.$.nick.value,
- onMessageSent: "messageSent",
- onMessageReceived: "messageReceived",
- onConnect: "connected"
- });
+ var chat_client = this.$.irc_client;
+ chat_client.setHost(this.$.host.value);
+ chat_client.setPort(this.$.port.value);
+ chat_client.setNick(this.$.nick.value);
this.$.irc_client.connect();
this.appendLog("<p>Connecting ...</p>");
},
@@ -54,5 +49,21 @@ enyo.kind({
},
appendLog:function(message){
this.$.log.setContent(this.$.log.content + message);
+ this.$.scroller.scrollToBottom();
+ },
+ checkMessage:function(sender, event, value){
+ if (value && value.trim() != "") {
+ this.$.sendButton.setDisabled(false);
+ };
+ },
+ sendOnEnter:function(sender, event){
+ if (event.which == 13) {
+ this.sendMessage(sender, event, this.$.messageInput.value);
+ event.preventDefault();
+ };
+ },
+ sendMessage:function(sender, event, value){
+ this.$.messageInput.setValue('');
+ this.$.irc_client.write(value + "\r\n");
}
});
View
2  chatty.application/index.html
@@ -3,6 +3,8 @@
<head>
<title>Chatty</title>
<meta charset="utf-8">
+ <script src="/opt/PalmSDK/0.1/share/refcode/framework/enyo/1.0/framework/enyo.js" type="text/javascript" launch="nobridge"></script>
+
</head>
<body>
<script type="text/javascript" charset="utf-8">
View
4 chatty.service/ClientAssistant.js
@@ -20,7 +20,7 @@ var ClientManager = function(){
}
this.getClient = function(clientId){
- return clients[client.id];
+ return clients[clientId];
}
}
@@ -38,7 +38,7 @@ ClientAssistant.prototype.createConnection = function(){
}
ClientAssistant.prototype.getClient = function(clientId){
- return this.manager.getClient(client.id);
+ return this.manager.getClient(clientId);
}
ClientAssistant.prototype.setup = function(){
Please sign in to comment.
Something went wrong with that request. Please try again.