Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
alvagi
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
alvagi
Commits
9d48a279
Commit
9d48a279
authored
Jun 11, 2015
by
antirek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add options
parent
d859b7d1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
9 deletions
+21
-9
app.js
app.js
+5
-4
context.js
lib/context.js
+6
-2
index.js
lib/index.js
+10
-3
No files found.
app.js
View file @
9d48a279
...
...
@@ -3,11 +3,12 @@ var AGIServer = require('./lib/index');
var
handler
=
function
(
context
)
{
context
.
onEvent
(
'
variables
'
)
.
then
(
function
(
vars
)
{
return
context
.
streamFile
(
'
beep
'
);
return
context
.
streamFile
(
'
beep
'
);
})
.
then
(
function
(
result
)
{
return
context
.
end
();
});
};
var
agi
=
new
AGIServer
(
handler
);
agi
.
start
(
3000
);
//ding.createServer(handler).listen(3000);
agi
.
start
(
3000
);
\ No newline at end of file
lib/context.js
View file @
9d48a279
...
...
@@ -3,8 +3,9 @@ var EventEmitter = require('events').EventEmitter;
var
state
=
require
(
'
./state
'
);
var
Q
=
require
(
'
q
'
);
var
Context
=
function
(
stream
)
{
var
Context
=
function
(
stream
,
debug
)
{
EventEmitter
.
call
(
this
);
this
.
debug
=
debug
;
this
.
stream
=
new
Readable
();
this
.
stream
.
wrap
(
stream
);
this
.
state
=
state
.
init
;
...
...
@@ -97,7 +98,10 @@ Context.prototype.end = function () {
Context
.
prototype
.
sendCommand
=
function
(
command
)
{
var
defer
=
new
Q
.
defer
();
this
.
send
(
command
+
'
\n
'
,
function
(
err
,
result
){
if
(
this
.
debug
)
console
.
log
(
'
command
'
,
command
);
var
self
=
this
;
this
.
send
(
command
+
'
\n
'
,
function
(
err
,
result
)
{
if
(
self
.
debug
)
console
.
log
(
'
err:
'
,
err
,
'
result:
'
,
result
);
if
(
err
)
{
defer
.
reject
(
err
);
}
else
{
...
...
lib/index.js
View file @
9d48a279
var
Context
=
require
(
'
./context
'
);
var
agi
=
function
(
handler
)
{
var
agi
=
function
(
handler
,
optionsIn
)
{
var
server
;
var
options
=
optionsIn
||
{};
var
settings
=
{
port
:
options
.
port
||
3000
,
debug
:
options
.
debug
||
false
};
var
handle
=
function
(
stream
)
{
var
context
=
new
Context
(
stream
);
var
context
=
new
Context
(
stream
,
settings
.
debug
);
handler
(
context
);
};
var
start
=
function
(
port
)
{
var
start
=
function
(
portIn
)
{
var
port
=
portIn
||
settings
.
port
;
return
require
(
'
net
'
).
createServer
(
handle
).
listen
(
port
);
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment