iamkinetic / neventsocket Goto Github PK
View Code? Open in Web Editor NEWThis project forked from danbarua/neventsocket
A reactive FreeSwitch eventsocket library for .Net/.Net Framework (.net standard 2)
License: Mozilla Public License 2.0
This project forked from danbarua/neventsocket
A reactive FreeSwitch eventsocket library for .Net/.Net Framework (.net standard 2)
License: Mozilla Public License 2.0
some code like these :
using (var socket = await InboundSocket.Connect("192.168.1.100", 8021, "123456789"))
{
//Tell FreeSwitch which events we are interested in
// await socket.SubscribeEvents(EventName.All);
await socket.SubscribeEvents(EventName.ChannelAnswer,EventName.ChannelCreate);
//Handle events as they come in using Rx
socket.ChannelEvents.Where(x => (x.EventName == EventName.ChannelAnswer
|| x.EventName == EventName.ChannelCreate
|| x.EventName == EventName.ChannelHangup
|| x.EventName == EventName.ChannelHangupComplete
|| EventName.ChannelOriginate == x.EventName
|| x.EventName == EventName.ChannelDestroy))
.Subscribe(async x =>
{
Console.WriteLine("Channel Answer Event " + x.UUID);
//we have a channel id, now we can control it
await socket.Play(x.UUID, "misc/8000/misc-freeswitch_is_state_of_the_art.wav");
});
var apiResponse = await socket.SendApi("status");
Console.WriteLine(apiResponse.BodyText);
Console.WriteLine((await socket.SendApi("status")).BodyText);
Console.WriteLine();
Console.WriteLine((await socket.SendApi("invalid_api_command")).BodyText);
Console.WriteLine();
Console.WriteLine((await socket.SendApi("sofia status")).BodyText);
Console.WriteLine();
Console.WriteLine((await socket.SendApi("show bridged_calls")).BodyText);
Console.WriteLine("Press [Enter] to exit.");
Console.ReadLine();
}
SendApi(...) looks ok . but xxxxx. .Subscribe(async x =>..... nothing happen at all when i use microsip for some dials .
i need some help for my question . please.. .
Examples cannot run. tips: Net.Reflection, Net.System, Net.Text not found!
I was following the Demo https://github.com/iamkinetic/NEventSocket/blob/master/NEventSocket.Examples/Examples/DtmfExample.cs
But the program crashes since ChannelData.UUID is null.
I am using Freeswitch 1.10.6, with default configuration
For the softphones I used MicroSip and PhonerLite
the OS is Windows10
To Reproduce
Steps to reproduce the behavior:
namespace Test_FSw
{
class Program
{
static async Task Main(string[] args)
{
NEventSocket.Logging.Logger.Configure(new LoggerFactory());
InboundSocket client;
client = await InboundSocket.Connect("localhost", 8021, "ClueCon", TimeSpan.FromSeconds(20));
var originate = await client.Originate("user/1001", new OriginateOptions
{
CallerIdNumber = "123456789",
CallerIdName = "test2",
HangupAfterBridge = false,
TimeoutSeconds = 20
});
if (!originate.Success)
{
Console.WriteLine("Failed");
Console.WriteLine(originate.HangupCause.ToString());
await client.Exit();
}
else
{
Console.WriteLine(originate.ChannelData.UUID);/*UUID or ChannelData is null*/
var uuid = originate.ChannelData.UUID;
/*unreached code*/
await client.SubscribeEvents(EventName.Dtmf);
}
Console.WriteLine("Exit[Enter]");
Console.ReadLine();
}
}
}
`
4. Execute
I created a simple program and got Value cannot be null. (Parameter 'factory') from Microsoft.Extensions.Logging.Abstractions
code as follows :
using System;
using System.Reactive.Linq;
using System.Threading.Tasks;
using NEventSocket;
using NEventSocket.FreeSwitch;
namespace ConsoleApp1
{
class Program
{
static async Task Main(string[] args)
{
await CallTracking();
Console.WriteLine("Hello World!");
}
public static async Task CallTracking()
{
using (var socket = await InboundSocket.Connect("XXX.XXX.XXX.XXX", 8021, "ClueCon"))
{
var apiResponse = await socket.SendApi("status");
Console.WriteLine(apiResponse.BodyText);
//Tell FreeSwitch which events we are interested in
await socket.SubscribeEvents(EventName.ChannelAnswer);
//Handle events as they come in using Rx
socket.ChannelEvents.Where(x => x.EventName == EventName.ChannelAnswer)
.Subscribe(async x =>
{
Console.WriteLine("Channel Answer Event " + x.UUID);
//we have a channel id, now we can control it
await socket.Play(x.UUID, "misc/8000/misc-freeswitch_is_state_of_the_art.wav");
});
}
}
}
}
any ideas ??
i am using .net core 3.1
Is your feature request related to a problem? Please describe.
The documentation is not up to date. Some work needs to be done.
For beginners, I don't need to care about NEventSocket.Tests. I just need to introduce the NEventSocket class library in my own project, and call InboundSocket.cs and OutboundListener.cs during project execution. Can I just listen? Is there a demo that can be run directly.
Solution builds ok on Net Core 2.x. But when changing to Net Core 3.0, example project doesn't build. Get a lot of errors like:
'ILifetimeScope' does not contain a definition for 'ImplementationsFor' and no accessible extension method 'ImplementationsFor' accepting a first argument of type 'ILifetimeScope' could be found
Guess some extensions are missing in Net Core 3.x.
Any ideas?
Best regards, Gregor
'“string”未包含“To”的定义,并且找不到可接受第一个“string”类型参数的可访问扩展方法“To”(是否缺少 using 指令或程序集引用?)NEventSocket.Examples\NetCore\CommandLineReader.cs
'“PropertyInfo”未包含“GetAttribute”的定义,并且找不到可接受第一个“PropertyInfo”类型参数的可访问扩展方法“GetAttribute”(是否缺少 using 指令或程序集引用?) NEventSocket.Examples\NetCore\CommandLineReader.cs
命名空间“Net”中不存在类型或命名空间名“System”(是否缺少程序集引用?) NEventSocket.Examples K:\FSEventSocket\NEventSocket.Examples\NetCore\CommandLineReader.cs
命名空间“Net”中不存在类型或命名空间名“Text”(是否缺少程序集引用?) NEventSocket.Examples K:\FSEventSocket\NEventSocket.Examples\NetCore\CommandLineReader.cs
ITNOA
Is your feature request related to a problem? Please describe.
This feature request is aimed at accessing the events published by freeswitch regarding it's VoiceMail functionality.
Describe the solution you'd like
Natively supporting Event Headers and Messages in a structured way pertaining to Voice mail module of freeswitch.
Describe alternatives you've considered
while these events can be manually parsed as any other custom event at a higher layer, It is preferable to Implement the parsing of these events data alongside other custom events to prevent code duplication and move logic closer to data.
I was using InboundSocket to originate some calls and play Audio files, and sometimes i got an ThrowInvalidOperationException_ConcurrentOperationsNotSupported where I called Play(...).
Here is the call stack:
System.ThrowHelper.ThrowInvalidOperationException_ConcurrentOperationsNotSupported()
System.Collections.Generic.HashSet<T>.FindItemIndex(T)
System.Collections.Generic.HashSet<T>.Contains(T)
NEventSocket.Sockets.EventSocket.SubscribeEvents.AnonymousMethod__28_0(NEventSocket.FreeSwitch.EventName)
System.Linq.Enumerable.All<TSource>(System.Collections.Generic.IEnumerable<TSource>, System.Func<TSource, bool>)
NEventSocket.Sockets.EventSocket.SubscribeEvents(NEventSocket.FreeSwitch.EventName[])
NEventSocket.Sockets.EventSocket.ExecuteApplication(string, string, string, bool, bool, int)
NEventSocket.ApplicationExtensions.Play(NEventSocket.Sockets.EventSocket, string, string, NEventSocket.FreeSwitch.PlayOptions)
I checked the library and I noticed the use of HashSet:
private readonly HashSet<EventName> subscribedEvents = new HashSet<EventName>();
Am I missing something or is it really not Thread-Safe ?
Let's release version 1.0.
ITNOA
Hi
Is this library alive?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.