Is socket's "leave" automatically converted to "left" for the receiver? - angularjs

In my code, I use WebRTC, AngularJS and rtpConnection.
One declare is:
https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.2.0/socket.io.js
In my code, I react to the following event:
socket.on("left", somevar)
However, I don't see where this is emitted, I searched just anywhere in my code.
But I just don't find any .emit("left" or ".emit('left' in my code.
The only code that is SOMEWHAT related is
socket.emit('leave', somevar);
But I just don't understand it: "leave" is not "left".
The only possible explanation would be that "leave" is internally converted to "left" for the receiver.
Is that actutally the case?
If not, where else could I find this emitting code?

No, socket doesn't do this automatically.
It's stated in the code somewhere by you.

Related

How do you represent a function call as an if condition statement in Sequence Diagram?

I've been drawing a sequence diagram of a module recently, while reverse engineering.
I encountered a control statement, and it is like,
if (func_A() == True)
{
DoSomeThing();
}
else
{
DoSomeThingElse();
}
The problem is how to draw the condition?
As I mentioned, It is reverse engineering. The code cannot be modified now.
I drew two diagrams, and I don't know which way is right,
The first one is this, I think it's wrong because it doesn't show the function call as a message from A to B.
This is the second, It shows a message func_A.
What do you think about to do this right?
To complete the other answer there is anyway a problem in the second proposal because we do not know if in [func_A() == True] you reuse the value return by the previous call or you do a second call, to avoid that add the explicit return in your diagram :
Out of that do you know the activities ? A sequence diagram is "just" an interaction while an activity is a behavior and can be more adapted :
It depends. If func_A is an operation defined in Object2 the second representation would be correct. The first does not tell where the operation is defined. Most likely (!) one would interpret func_A as an operation local to ObjectA which your code seems to say. (Btw. you have two completely different object sets AB vs. 12 in your examples.) But that is uncertain. So the 2nd variant is more explicit (and correct).
In any case I advise to not overdo SDs with fragments as "graphical programming" doesn't make things easier to read (my practical experience). It's excellent to show message flows in various collaborations. But when it comes to conditions it's getting messy very soon. A better way is to create different sub-diagrams or even use pseudo code if there are too nested if conditions. In many cases such if clauses are a good fit for state machines.

What does "?" in shape(?,12) means in keras?

While making a machine learning model in keras, I checked the shape of an element that gives the output (?,12).
I went through this
stackoverflow answer but did'nt understand what exactly (?,12) shows?
it means it's a variable shape. This could be for example the batch size.
Have a look at What is the meaning of the "None" in model.summary of KERAS?

I started to using mothur version - v.1.36.1-, but I got some error messages (shown below). How I can overcome this?

I start the Mothur Tutorial (https://www.mothur.org/wiki/MiSeq_SOP). But from the beginning, I got some error messages when I create " make.file "in mothur*(Error commands are shown below). I changed parameters but the result was negative. How can I solve this problem?
****mothur > make.file(inputdir=MiSeq_SOP, type=fastq, prefix=stability)
Setting input directory to: MiSeq_SOP/
prefix is not a valid parameter.
The valid parameters are: type, seed, inputdir, and outputdir.
[ERROR]: did not complete make.file.****
Actually, the prefix parameter is a valid parameter in mothur. Personally, I have never encountered a problem with using a prefix for the make.file command, but your command should be valid.
You could test if your inputdir is specified correctly (the mothur error and warning messages are not necessarily the most clear ones). If this works as well, I suggest that you well document this behaviour and send it to the mothur team (in my experience, they are quite responsive and ready to help).

How to insert print for each function of C language for debugging?

I am studying and debugging one software. There are thousands of functions in this software. I plan to add printf() at the entry and exit point of each function. It will take a lot of time.
Is there one tool/script to do this?
I may use '__cyg_profile_func_enter'. But it can only get address. But I have to run another script to get function name. I also hope to get value of input parameters of this function too.
You should give a try to AOP : Aspect Oriented Programming. Personnaly I've only tried with Java and Spring AOP but there's an API for C too : AspectC (https://sites.google.com/a/gapp.msrg.utoronto.ca/aspectc/home). From what I've seen, it's not the only one.
From what I've red about this library, you can add an pointcut before compiling with AspectC :
// before means it's a before function aspect
// call means it's processed when a function is called
// args(...) means it applies to any function with any arguments
// this->funcName is the name of the function handled by AspectC
before(): call(args(...)) {
printf("Entering %s\n", this->funcName);
}
(not tried by myself but extracted from the reference page https://sites.google.com/a/gapp.msrg.utoronto.ca/aspectc/tutorial)
This is only a basic overview of what can be done and you still have to deal with the compilation (documented in the page linked before) but it looks like it could possibly help you. Give a try with a simple POC maybe.

How can I do a complex IF statement in visualforce?

I'm totally new to this, the task has been thrown at me as important and I've never done anything like this before. I have been given a template containing roughly this:
<apex:column headervalue="Amount"><c2g:CODAFormatterController number="{!IF([some condition],[something],[something else])}"/></apex:column>
I've replaced the statements with condition/something/something else
is there a way to use a function as you'd do in javascript, so something like
number="getNumber(x);"
or do I have to chain some IF statements together somehow? Is there an IF...ELSE?
I don't know what a CODAFormatterController is as it returned 0 results on google.
Any advice would help, I'm afraid I've been thrown in at the deep end here!
The VForce inlines are functional, they must ultimately return a value, be that a simple value or an invocation point for a piece of server side code. They do not support imperative coding and they are being resolved server-side (long before JS comes into play). in that regard the IF(condition,valuetrue,valuefalse) is an equivalent to IF..THEN..ELSE..ENDIF
You are off course free to chain any number of functions provided there is no type mismatch, meaning your valuetrue could itself be a function, including being an IF function itself.
Usually when people encounter these kind of problems there is always a workaround by using a slightly different approach. It all depends on what you are trying to do here...
I stumbled upon this question while doing some work myself on visualforce pages. Anyway, if anybody else sees this question they should know that there's no need to use the complicated nested IF statements, now there is a CASE function available in Salesforce.
Documentation - https://developer.salesforce.com/docs/atlas.en-us.198.0.pages.meta/pages/pages_variables_functions.htm
{!CASE(Opportunity.StageName,
"Prospecting", "1",
"Needs Analysis", "2",
"Proposal/Price Quote", "3",
"default val")} <!-- the last one returns if none of the previous results matched -->

Resources