i am a beginner in signalR and Need to make an application where there are many users having many roles, and there should be three channels of sending notification to clients
1. Public (Used For All)
2. Private (Sending Notification to Single Person)
3. Group and Sub Group (Sending Notification to the persons who are member of some group or sub-group)
Problem is i am unable to understand the user differentiation in SignalR and not getting the concept of groups.
Anyone please Guide me
First of all, you can start to read the Microsoft documentation about the groups. Then you can read the authorization documentation so you would be able to create groups and manage users for each role.
What you can do is, when the client connects to the Hub, and assuming you know the users role (using the context and the authorization) you will add them to those 3 groups.
Then it is easy to send message to those groups, you have such examples everywhere in the stackOverflow and the internet.
Hope this helps you.
Code example:
/// <summary>
/// Called when a new connection is established with the hub.
/// </summary>
/// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
public override async Task OnConnectedAsync()
{
// 1. Add the use to the public group
await this.Groups.AddToGroupAsync( this.Context.ConnectionId, "PublicGroup");
// 2. Add user to the private channel, single person
await this.Groups.AddToGroupAsync(this.Context.ConnectionId, this.Context.User.Identity.Name);
if (this.Context.User.IsInRole("Admin"))
{
// 3. Add the user to the Admin group
await this.Groups.AddToGroupAsync(this.Context.ConnectionId, "Admin");
}
// add to other groups...
await base.OnConnectedAsync();
}
Related
I'm trying to send a message to user, who joined to a group, with my telegram bot. I add bot to the group and bot is admin in group. and I set the Group Privacy off. I get user with new_chat_member when user joined to group, but the message send to user infinitely. And the update which is for when a member join to group is pending.
if(isset($arrayMessage['message'])) {
if (isset($arrayMessage['message']['new_chat_member'])) {
$text= "hello!";
$url= "https://api.telegram.org/bot".$token."/sendMessage?chat_id=".$chat_id."&text=".$text;
file_get_contents($url);
}
}
I'll assume you are using long polling for this answer. When using the getUpdates method, it will keep retrieving the existing unconfirmed updates until you confirm them by using the offset parameter.
See enter link description here
If you do not confirm the updates, you will keep receiving the same update, thus the infinite messages.
I'm using the MSFT Bot Framework to build a team bot but my bot is only relevant to my organization. Actually I don't want anyone outside my organization to be able to talk to it.
I've been looking how to limit my bot to a specific Office 365 organization but can't find how to do it. The only thing I can find is using the other party userstring to see in which org they live.
My question:
Is ther a way to limit my bot to a single O365 organization?
Thanks
Bram
Its been 2 years but there's no real answer and it popped up in my related list tho...
These days you can write an easy simple middleware that does the tenant filtering like here:
public static string TenantFilterSettingAny = "#ANY#";
/// <summary>
/// Here are below scenarios -
/// #Scenario 1 - Reject the Bot If Tenant is configured in web.config and doesn't match with Incoming request tenant
/// #Scenario 2 - Allow Bot for every Tenant if Tenant is not configured in web.config file and default value is #ANY#
/// </summary>
/// <param name="activity"></param>
/// <param name="currentTenant"></param>
/// <returns></returns>
public static bool RejectMessageBasedOnTenant(IMessageActivity activity, string currentTenant)
{
if (!String.Equals(ConfigurationManager.AppSettings["OFFICE_365_TENANT_FILTER"], TenantFilterSettingAny))
{
//#Scenario 1
return !string.Equals(ConfigurationManager.AppSettings["OFFICE_365_TENANT_FILTER"], currentTenant);
}
else
{
//Scenario 2
return false;
}
}
Its taken from this sample
The most reliable way right now is to implement authentication of users, as demonstrated in AuthBot, and then check the tenant-id of the logged-in user.
Does the Azure Service Bus Subscription client support the ability to use OnMessage Action when the subscription requires a session?
I have a subscription, called "TestSubscription". It requires a sessionId and contains multipart data that is tied together by a SessionId.
if (!namespaceManager.SubscriptionExists("TestTopic", "Export"))
{
var testRule = new RuleDescription
{
Filter = new SqlFilter(#"(Action='Export')"),
Name = "Export"
};
var subDesc = new SubscriptionDescription("DataCollectionTopic", "Export")
{
RequiresSession = true
};
namespaceManager.CreateSubscription(sub`enter code here`Desc, testRule);
}
In a seperate project, I have a Service Bus Monitor and WorkerRole, and in the Worker Role, I have a SubscriptionClient, called "testSubscriptionClient":
testSubscriptionClient = SubscriptionClient.CreateFromConnectionString(connectionString, _topicName, CloudConfigurationManager.GetSetting("testSubscription"), ReceiveMode.PeekLock);
I would then like to have OnMessage triggered when new items are placed in the service bus queue:
testSubscriptionClient.OnMessage(PersistData);
However I get the following message when I run the code:
InvalidOperationException: It is not possible for an entity that requires sessions to create a non-sessionful message receiver
I am using Azure SDK v2.8.
Is what I am looking to do possible? Are there specific settings that I need to make in my service bus monitor, subscription client, or elsewhere that would let me retrieve messages from the subscription in this manner. As a side note, this approach works perfectly in other cases that I have in which I am not using sessioned data.
Can you try this code:
var messageSession=testSubscriptionClient.AcceptMessageSession();
messageSession.OnMessage(PersistData);
beside of this:
testSubscriptionClient.OnMessage(PersistData);
Edit:
Also, you can register your handler to handle sessions (RegisterSessionHandler). It will fire your handle every new action.
I think this is more suitable for your problem.
He shows both way, in this article. It's for queue, but I think you can apply this to topic also.
I want to preset the nickname of the sender which will be shown at the receiver's end while sending the Glympse Ticket.
Issue :- When first time the sender is sending a Glympse it asks for Saving and Sending with a nick name, rather I have already set a nick name with the code detailed below.
GGlympseLite glympse = GlympseLiteWrapper.instance().getGlympse();
glympse.setNickname(DCCApplication.session.getName());
While the above code works fine from the second time onwards, but it asks for the Nick Name when the user is sending the Glympse for First Time, and it asks for the nickname everytime till the User has entered once in that popup.
Please let me know why is it so?
Thanks
Your code for setting the nickname is perfect, but there is one very recent change in our SDK that is causing it to not set properly. The Glympse platform must be synchronized with the server before calling setNickname(). This change is mentioned under 2.6.54 in our change log:
https://developer.glympse.com/Content/client/full/android/guides/Glympse_Api_Android_Changelog.html
Implement GListenerLite as specified here:
Glympse API - Handle Send Ticket Operation
And listen for the LC.EVENT_SYNCED event.
#Override public void eventsOccurred(GGlympseLite glympse, int event, Object param1, Object param2)
{
if (0 != (event & LC.EVENT_SYNCED))
{
Log.d("", "Synced with server");
GlympseLiteWrapper.instance().getGlympse().setNickname(DCCApplication.session.getName());
}
}
I have a custom workflow done in Visual Studio 2010 (for SharePoint 2010 site). I have a task assigned to a group. All users receive task assignment notification emails without any problem. By default any of them approving it shows the task as completed.
My task will be considered approved only when ALL members of the group approve that. How to achieve this please?
Any help will be appreciated.
Thanks
Every time I've seen multi-approval workflows, it has always included multiple tasks. I don't think a single task can be some percentage approved. It's either pending or approved (or denied, etc).
I can think of two possibilities:
In your custom workflow, at the time that the task is being assigned, rather than assigning a single task to the group, assign one task to each member of the group.
Add an ItemUpdating event receiver to the Task list item that maintains (another list, database, etc?) a list of users have approved the task. Once all users in the group have approved the task, allow the update to go through, otherwise leave the status as pending.
Try keeping track of the number of individual tasks assigned and individual tasks completed. When completed==assigned, check to make sure all tasks resulted in approval and take the required action from there.
Technically you could create a custom task type that uses a different field, and store all of the user names in it, and check them off one by one with a custom task form... but it's actually a lot simpler if you create multiple tasks in parallel.
Here is an example of how to do it, http://msdn.microsoft.com/en-us/library/hh128696.aspx (Watch the video too!) BUT-- there is one part of his example that's a bad practice: he initializes the InitialChildData IList inside the Initialzed event of the Replicator activity... that's why he has to initialize the first child in there, and the rest in the ChildInitialized event... the correct way is to have a code activity run immediately before you get to the replicator and set up your IList. Then you can just leave all of the actual initialization code in the childInitialized handler. In my real life working version I have no replicator initialized handler at all.
I'm about to go into an example that goes along with the Scot Hilier one linked above, like an errata addendum type thing, so don't get upset when you realize this code isn't the entire solution.
For example, if my multi approver list is using a comma delimited string property of my workflow called Assignees (maybe I get it from the intialization data of the workflow, maybe a previous task form... that's your own business)
private void prepareCodeActivity_Invoked(object sender, EventArgs e) {
Assignees = DesignatedApprovers.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList();
}
Assignees is a List<string> in this case, and I have bound the InitialChildData property of the replicator to it
private void replicateTasks_ChildInitialized(object sender, ReplicatorChildEventArgs e) {
// do all of your task setup here (e.InstanceData is the single string for this child)
// note I'm setting properties of my custom activity, not the task itself
// each child instance of the replicator gets it's own instance of it.
generalApprovalTask.TaskAssignedTo = e.InstanceData.ToString();
generalApprovalTask.TaskTitle = string.Format(MyStrings.GeneralApprovalTaskTitle,
workflowProperties.Item.File.Name)
// log something!
}
Just a small oversight by Mr Hillier, but it's generally a good example, so we'll forgive him.
If you want to examine the results, do it in the ChildCompleted handler of the replicator. (Mr Hilier does not cover this part either.)
public int FailedApprovals { get; set; }
/// <summary>
/// This is called upon the completion of the child tasks. Here is where we check the outcome.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void replicateTasks_ChildCompleted(object sender, ReplicatorChildEventArgs e) {
if (e.Activity is MyGeneralApprovalTaskActivity) {
var act = e.Activity as MyGeneralApprovalTaskActivity;
if (act.TheTaskOutcome != MyStrings.ApprovedString) {
FailedApprovals++;
}
// log something!
}
}
It was suggested that a Replicator Activity with Until condition is the proper way to go for this. As per my research this sounds like a good solution.
http://wiki.windowsworkflowfoundation.eu/default.aspx/WF/UntilConditionAndTheReplicatorActivity.html
I welcome any further suggestions/approaches.